diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1f878ceb41..eb8ebf08d8 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3160,16 +3160,11 @@ parameters: - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" - count: 2 - path: src/Controllers/Sql/SqlController.php - - - - message: "#^Only booleans are allowed in an if condition, bool\\|null given\\.$#" count: 1 path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, mixed given\\.$#" + message: "#^Only booleans are allowed in an if condition, bool\\|null given\\.$#" count: 1 path: src/Controllers/Sql/SqlController.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 3de85cabe2..d30302ad41 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1194,11 +1194,9 @@ - - @@ -2800,7 +2798,6 @@ - @@ -2810,7 +2807,6 @@ - @@ -2823,11 +2819,9 @@ - - @@ -2835,12 +2829,6 @@ - - - - - - @@ -3525,14 +3513,12 @@ - getQueryParam('sql_query', true)]]> - diff --git a/src/Controllers/Database/SqlController.php b/src/Controllers/Database/SqlController.php index 3862c1a240..33d21444d9 100644 --- a/src/Controllers/Database/SqlController.php +++ b/src/Controllers/Database/SqlController.php @@ -37,7 +37,6 @@ class SqlController implements InvocableController public function __invoke(ServerRequest $request): Response { - $GLOBALS['back'] ??= null; $GLOBALS['errorUrl'] ??= null; $this->response->addScriptFiles(['makegrid.js', 'vendor/jquery/jquery.uitablefilter.js', 'sql.js']); @@ -75,7 +74,7 @@ class SqlController implements InvocableController * with the typed query in the textarea. */ UrlParams::$goto = Url::getFromRoute('/database/sql'); - $GLOBALS['back'] = UrlParams::$goto; + UrlParams::$back = UrlParams::$goto; $delimiter = $request->getParsedBodyParamAsString('delimiter', ';'); $this->response->addHTML($this->sqlQueryForm->getHtml( diff --git a/src/Controllers/Sql/SqlController.php b/src/Controllers/Sql/SqlController.php index 6f4cf193e8..90208d2949 100644 --- a/src/Controllers/Sql/SqlController.php +++ b/src/Controllers/Sql/SqlController.php @@ -49,7 +49,6 @@ class SqlController implements InvocableController $GLOBALS['message_to_show'] ??= null; $GLOBALS['disp_message'] ??= null; $GLOBALS['complete_query'] ??= null; - $GLOBALS['back'] ??= null; $this->pageSettings->init('Browse'); $this->response->addHTML($this->pageSettings->getErrorHTML()); @@ -83,7 +82,7 @@ class SqlController implements InvocableController } if (! isset($GLOBALS['errorUrl'])) { - $GLOBALS['errorUrl'] = ! empty($GLOBALS['back']) ? $GLOBALS['back'] : UrlParams::$goto; + $GLOBALS['errorUrl'] = UrlParams::$back !== '' ? UrlParams::$back : UrlParams::$goto; $GLOBALS['errorUrl'] .= Url::getCommon( ['db' => Current::$database], ! str_contains($GLOBALS['errorUrl'], '?') ? '?' : '&', diff --git a/src/Controllers/Table/SqlController.php b/src/Controllers/Table/SqlController.php index 8eb3c81e0c..3e0808f072 100644 --- a/src/Controllers/Table/SqlController.php +++ b/src/Controllers/Table/SqlController.php @@ -39,7 +39,6 @@ class SqlController implements InvocableController public function __invoke(ServerRequest $request): Response { $GLOBALS['errorUrl'] ??= null; - $GLOBALS['back'] ??= null; $this->response->addScriptFiles(['makegrid.js', 'vendor/jquery/jquery.uitablefilter.js', 'sql.js']); @@ -91,7 +90,7 @@ class SqlController implements InvocableController * with the typed query in the textarea. */ UrlParams::$goto = Url::getFromRoute('/table/sql'); - $GLOBALS['back'] = Url::getFromRoute('/table/sql'); + UrlParams::$back = Url::getFromRoute('/table/sql'); $delimiter = $request->getParsedBodyParamAsString('delimiter', ';'); $this->response->addHTML($this->sqlQueryForm->getHtml( diff --git a/src/Http/Middleware/UrlParamsSetting.php b/src/Http/Middleware/UrlParamsSetting.php index 1e7144cbf7..aa50c97e77 100644 --- a/src/Http/Middleware/UrlParamsSetting.php +++ b/src/Http/Middleware/UrlParamsSetting.php @@ -50,7 +50,7 @@ final class UrlParamsSetting implements MiddlewareInterface if ($back !== null && Core::checkPageValidity($back)) { // Returning page. - $GLOBALS['back'] = $back; + UrlParams::$back = $back; return; } diff --git a/src/UrlParams.php b/src/UrlParams.php index 460b79de38..5ade904d0d 100644 --- a/src/UrlParams.php +++ b/src/UrlParams.php @@ -12,4 +12,5 @@ class UrlParams /** @var array $params */ public static array $params = []; public static string $goto = ''; + public static string $back = ''; } diff --git a/tests/unit/Http/Middleware/UrlParamsSettingTest.php b/tests/unit/Http/Middleware/UrlParamsSettingTest.php index 0d4bf9a8a1..84dcd3f428 100644 --- a/tests/unit/Http/Middleware/UrlParamsSettingTest.php +++ b/tests/unit/Http/Middleware/UrlParamsSettingTest.php @@ -20,7 +20,7 @@ final class UrlParamsSettingTest extends AbstractTestCase { UrlParams::$params = []; UrlParams::$goto = ''; - $GLOBALS['back'] = null; + UrlParams::$back = ''; $request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/') ->withQueryParams(['goto' => 'index.php?route=/', 'back' => 'index.php?route=/']); @@ -34,11 +34,11 @@ final class UrlParamsSettingTest extends AbstractTestCase /** @psalm-suppress TypeDoesNotContainType */ self::assertSame('index.php?route=/', UrlParams::$goto); /** @psalm-suppress TypeDoesNotContainType */ - self::assertSame('index.php?route=/', $GLOBALS['back']); + self::assertSame('index.php?route=/', UrlParams::$back); /** @psalm-suppress TypeDoesNotContainType */ self::assertSame(['goto' => 'index.php?route=/'], UrlParams::$params); UrlParams::$goto = ''; - $GLOBALS['back'] = null; + UrlParams::$back = ''; } }