From 661ab4fd5d7e0ee27d1d60fb016c325cd5f058a6 Mon Sep 17 00:00:00 2001 From: Aziz Date: Thu, 1 Apr 2021 23:53:56 +0300 Subject: [PATCH 1/2] ISSUE-1500: Fix not found error on webtools --- CHANGELOG.md | 5 +++++ src/Bootstrap.php | 44 ++++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97a1dcd5a..f72163d95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# [4.0.7](https://github.com/phalcon/cphalcon/releases/tag/v4.0.7) +## Fixed +- Fixed not found error on webtools [#1500](https://github.com/phalcon/phalcon-devtools/issues/1500) + + # [4.0.6](https://github.com/phalcon/cphalcon/releases/tag/v4.0.6) (2021-03-22) ## Fixed - Fixed model findFirst return type error [#1478](https://github.com/phalcon/phalcon-devtools/issues/1478) diff --git a/src/Bootstrap.php b/src/Bootstrap.php index 260cd82f1..7cdde1e3c 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -203,7 +203,7 @@ public function __construct(array $parameters = []) */ public function run() { - if (PHP_SAPI == 'cli') { + if (PHP_SAPI === 'cli') { set_time_limit(0); } @@ -219,7 +219,7 @@ public function run() * * @return string */ - public function getOutput() + public function getOutput(): string { return $this->app->handle($this->getCurrentUri())->getContent(); } @@ -231,7 +231,7 @@ public function getOutput() * * @return $this */ - public function setPtoolsPath($path) + public function setPtoolsPath(string $path): Bootstrap { $this->ptoolsPath = rtrim($path, '\\/'); @@ -243,7 +243,7 @@ public function setPtoolsPath($path) * * @return string */ - public function getPtoolsPath() + public function getPtoolsPath(): string { return $this->ptoolsPath; } @@ -255,7 +255,7 @@ public function getPtoolsPath() * * @return $this */ - public function setPtoolsIp($ip) + public function setPtoolsIp(string $ip): Bootstrap { $this->ptoolsIp = trim($ip); @@ -267,7 +267,7 @@ public function setPtoolsIp($ip) * * @return string */ - public function getPtoolsIp() + public function getPtoolsIp(): string { return $this->ptoolsIp; } @@ -279,7 +279,7 @@ public function getPtoolsIp() * * @return $this */ - public function setBasePath($path) + public function setBasePath(string $path): Bootstrap { $this->basePath = rtrim($path, '\\/'); @@ -291,7 +291,7 @@ public function setBasePath($path) * * @return string */ - public function getBasePath() + public function getBasePath(): string { return $this->basePath; } @@ -303,7 +303,7 @@ public function getBasePath() * * @return $this */ - public function setTemplatesPath($path) + public function setTemplatesPath(string $path): Bootstrap { $this->templatesPath = rtrim($path, '\\/'); @@ -315,7 +315,7 @@ public function setTemplatesPath($path) * * @return string */ - public function getTemplatesPath() + public function getTemplatesPath(): string { return $this->templatesPath; } @@ -327,7 +327,7 @@ public function getTemplatesPath() * * @return $this */ - public function setMode($mode) + public function setMode(string $mode): Bootstrap { $mode = strtolower(trim($mode)); @@ -345,7 +345,7 @@ public function setMode($mode) * * @return string */ - public function getMode() + public function getMode(): string { return $this->mode; } @@ -357,7 +357,7 @@ public function getMode() * * @return $this */ - public function setHostName($name) + public function setHostName(string $name): Bootstrap { $this->hostName = trim($name); @@ -369,7 +369,7 @@ public function setHostName($name) * * @return string */ - public function getHostName() + public function getHostName(): string { return $this->hostName; } @@ -381,7 +381,7 @@ public function getHostName() * @return $this * @throws InvalidArgumentException */ - public function setParameters(array $parameters) + public function setParameters(array $parameters): Bootstrap { foreach ($this->configurable as $param) { if (!isset($parameters[$param])) { @@ -401,7 +401,7 @@ public function setParameters(array $parameters) * @param mixed $value The value * @return $this */ - public function setParameter(string $parameter, $value) + public function setParameter(string $parameter, $value): Bootstrap { $method = 'set' . Text::camelize($parameter); @@ -417,10 +417,10 @@ public function setParameter(string $parameter, $value) * * @return $this */ - public function initFromConstants() + public function initFromConstants(): Bootstrap { foreach ($this->defines as $const => $property) { - if (defined($const) && in_array($property, $this->configurable)) { + if (defined($const) && in_array($property, $this->configurable, true)) { $this->setParameter($property, constant($const)); } } @@ -430,8 +430,12 @@ public function initFromConstants() public function getCurrentUri(): string { - $webToolsFileName = basename($_SERVER['SCRIPT_FILENAME']); + $baseUrl = $this->di->getShared('url')->getBaseUri(); - return str_replace($webToolsFileName . '/', '', $_SERVER['REQUEST_URI']); + return str_replace( + basename($_SERVER['SCRIPT_FILENAME']), + '', + substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $baseUrl) + strlen($baseUrl)) + ); } } From c288f71d7d445bb77c9dcbf08ccaa72aa57a3244 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Sun, 4 Apr 2021 22:53:53 +0100 Subject: [PATCH 2/2] Bump version to 4.0.7 --- src/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Version.php b/src/Version.php index 81c8f0688..279062c04 100644 --- a/src/Version.php +++ b/src/Version.php @@ -27,7 +27,7 @@ class Version extends PhVersion // phpcs:disable protected static function _getVersion(): array { - return [4, 0, 5, 0, 0]; + return [4, 0, 7, 0, 0]; } // phpcs:enable }