Replace $GLOBALS['back']

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2024-11-10 20:01:33 +00:00 committed by Maurício Meneghini Fauth
parent 7ffd21eb79
commit 5d90836f17
8 changed files with 9 additions and 30 deletions

View File

@ -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

View File

@ -1194,11 +1194,9 @@
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['back']]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
</InvalidArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['back']]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
</MixedAssignment>
<PossiblyUnusedMethod>
@ -2800,7 +2798,6 @@
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['ajax_reload']]]></code>
<code><![CDATA[$GLOBALS['back']]]></code>
<code><![CDATA[$GLOBALS['disp_message']]]></code>
<code><![CDATA[$GLOBALS['disp_query']]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
@ -2810,7 +2807,6 @@
<MixedArgument>
<code><![CDATA[$GLOBALS['disp_message'] ?? null]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
<code><![CDATA[$GLOBALS['message_to_show'] ?? null]]></code>
<code><![CDATA[$GLOBALS['sql_query']]]></code>
<code><![CDATA[$GLOBALS['sql_query']]]></code>
@ -2823,11 +2819,9 @@
</MixedArrayAccess>
<MixedAssignment>
<code><![CDATA[$GLOBALS['ajax_reload']]]></code>
<code><![CDATA[$GLOBALS['back']]]></code>
<code><![CDATA[$GLOBALS['disp_message']]]></code>
<code><![CDATA[$GLOBALS['disp_query']]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
<code><![CDATA[$GLOBALS['message_to_show']]]></code>
<code><![CDATA[$GLOBALS['sql_query']]]></code>
<code><![CDATA[$GLOBALS['unlim_num_rows']]]></code>
@ -2835,12 +2829,6 @@
<code><![CDATA[$sqlQuery]]></code>
<code><![CDATA[$sqlQuery]]></code>
</MixedAssignment>
<MixedOperand>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
</MixedOperand>
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty($GLOBALS['back'])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Controllers/Table/AddFieldController.php">
<InvalidArrayOffset>
@ -3525,14 +3513,12 @@
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['back']]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$request->getQueryParam('sql_query', true)]]></code>
</MixedArgument>
<MixedAssignment>
<code><![CDATA[$GLOBALS['back']]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
</MixedAssignment>
</file>

View File

@ -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(

View File

@ -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'], '?') ? '?' : '&',

View File

@ -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(

View File

@ -50,7 +50,7 @@ final class UrlParamsSetting implements MiddlewareInterface
if ($back !== null && Core::checkPageValidity($back)) {
// Returning page.
$GLOBALS['back'] = $back;
UrlParams::$back = $back;
return;
}

View File

@ -12,4 +12,5 @@ class UrlParams
/** @var array<string, bool|int|string> $params */
public static array $params = [];
public static string $goto = '';
public static string $back = '';
}

View File

@ -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 = '';
}
}