Remove the ajax_reload global variable

Replaces it with a local variable.

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
Maurício Meneghini Fauth 2025-01-09 20:46:07 -03:00
parent f42d1b297c
commit 96cf13cac6
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
4 changed files with 15 additions and 52 deletions

View File

@ -2874,18 +2874,6 @@ parameters:
count: 6
path: src/Controllers/Import/ImportController.php
-
message: '#^Cannot access offset ''reload'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 4
path: src/Controllers/Import/ImportController.php
-
message: '#^Cannot access offset ''table_name'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Controllers/Import/ImportController.php
-
message: '#^Casting to string something that''s already string\.$#'
identifier: cast.useless
@ -2907,7 +2895,7 @@ parameters:
-
message: '#^If condition is always false\.$#'
identifier: if.alwaysFalse
count: 1
count: 2
path: src/Controllers/Import/ImportController.php
-
@ -2934,12 +2922,6 @@ parameters:
count: 1
path: src/Controllers/Import/ImportController.php
-
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
identifier: if.condNotBoolean
count: 1
path: src/Controllers/Import/ImportController.php
-
message: '#^Parameter \#2 \$size of method PhpMyAdmin\\Import\\Import\:\:getNextChunk\(\) expects int, float\|int\<min, \-1\>\|int\<1, max\> given\.$#'
identifier: argument.type
@ -2976,6 +2958,12 @@ parameters:
count: 1
path: src/Controllers/Import/ImportController.php
-
message: '#^Strict comparison using \=\=\= between false and false will always evaluate to true\.$#'
identifier: identical.alwaysTrue
count: 1
path: src/Controllers/Import/ImportController.php
-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
identifier: empty.notAllowed
@ -3735,12 +3723,6 @@ parameters:
count: 1
path: src/Controllers/Sql/SqlController.php
-
message: '#^Cannot access offset ''reload'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Controllers/Sql/SqlController.php
-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
identifier: notEqual.notAllowed

View File

@ -1528,11 +1528,6 @@
<code><![CDATA[UrlParams::$params]]></code>
</MixedArgumentTypeCoercion>
<MixedArrayAssignment>
<code><![CDATA[$GLOBALS['ajax_reload']['reload']]]></code>
<code><![CDATA[$GLOBALS['ajax_reload']['reload']]]></code>
<code><![CDATA[$GLOBALS['ajax_reload']['reload']]]></code>
<code><![CDATA[$GLOBALS['ajax_reload']['reload']]]></code>
<code><![CDATA[$GLOBALS['ajax_reload']['table_name']]]></code>
<code><![CDATA[$_SESSION['Import_message']['go_back_url']]]></code>
<code><![CDATA[$_SESSION['Import_message']['go_back_url']]]></code>
<code><![CDATA[$_SESSION['Import_message']['go_back_url']]]></code>
@ -1540,7 +1535,6 @@
<code><![CDATA[$_SESSION['Import_message']['message']]]></code>
</MixedArrayAssignment>
<MixedAssignment>
<code><![CDATA[$GLOBALS['ajax_reload']]]></code>
<code><![CDATA[$GLOBALS['message_to_show']]]></code>
<code><![CDATA[$GLOBALS['result']]]></code>
<code><![CDATA[$GLOBALS['show_as_php']]]></code>
@ -2288,11 +2282,7 @@
<code><![CDATA[$GLOBALS['message_to_show'] ?? '']]></code>
<code><![CDATA[$request->getQueryParam('sql_signature')]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$GLOBALS['ajax_reload']['reload']]]></code>
</MixedArrayAccess>
<MixedAssignment>
<code><![CDATA[$GLOBALS['ajax_reload']]]></code>
<code><![CDATA[$GLOBALS['disp_message']]]></code>
<code><![CDATA[$GLOBALS['disp_query']]]></code>
<code><![CDATA[$GLOBALS['message_to_show']]]></code>

View File

@ -61,7 +61,6 @@ final class ImportController implements InvocableController
public function __invoke(ServerRequest $request): Response
{
$GLOBALS['ajax_reload'] ??= null;
$GLOBALS['result'] ??= null;
ImportSettings::$charsetOfFile = $request->getParsedBodyParamAsString('charset_of_file', '');
@ -78,7 +77,7 @@ final class ImportController implements InvocableController
// default values
ResponseRenderer::$reload = false;
$GLOBALS['ajax_reload'] = [];
$ajaxReload = [];
Import::$importText = '';
// Are we just executing plain query or sql file?
// (eg. non import, but query box/window run)
@ -122,12 +121,12 @@ final class ImportController implements InvocableController
// refresh navigation and main panels
if (preg_match('/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', Current::$sqlQuery) === 1) {
ResponseRenderer::$reload = true;
$GLOBALS['ajax_reload']['reload'] = true;
$ajaxReload['reload'] = true;
}
// refresh navigation panel only
if (preg_match('/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', Current::$sqlQuery) === 1) {
$GLOBALS['ajax_reload']['reload'] = true;
$ajaxReload['reload'] = true;
}
// do a dynamic reload if table is RENAMED
@ -139,8 +138,8 @@ final class ImportController implements InvocableController
$renameTableNames,
) === 1
) {
$GLOBALS['ajax_reload']['reload'] = true;
$GLOBALS['ajax_reload']['table_name'] = Util::unQuote($renameTableNames[2]);
$ajaxReload['reload'] = true;
$ajaxReload['table_name'] = Util::unQuote($renameTableNames[2]);
}
Current::$sqlQuery = '';
@ -275,14 +274,14 @@ final class ImportController implements InvocableController
// refresh navigation and main panels
if (preg_match('/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', Import::$importText) === 1) {
ResponseRenderer::$reload = true;
$GLOBALS['ajax_reload']['reload'] = true;
$ajaxReload['reload'] = true;
}
// refresh navigation panel only
if (
preg_match('/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', Import::$importText) === 1
) {
$GLOBALS['ajax_reload']['reload'] = true;
$ajaxReload['reload'] = true;
}
break;
@ -664,7 +663,7 @@ final class ImportController implements InvocableController
);
}
$this->response->addJSON('ajax_reload', $GLOBALS['ajax_reload']);
$this->response->addJSON('ajax_reload', $ajaxReload);
$this->response->addHTML($htmlOutput);
return $this->response->response();

View File

@ -42,7 +42,6 @@ class SqlController implements InvocableController
public function __invoke(ServerRequest $request): Response
{
$GLOBALS['ajax_reload'] ??= null;
$GLOBALS['unlim_num_rows'] ??= null;
$GLOBALS['disp_query'] ??= null;
$GLOBALS['message_to_show'] ??= null;
@ -59,13 +58,6 @@ class SqlController implements InvocableController
'multi_column_sort.js',
]);
/**
* Set ajax_reload in the response if it was already set
*/
if (isset($GLOBALS['ajax_reload']) && $GLOBALS['ajax_reload']['reload'] === true) {
$this->response->addJSON('ajax_reload', $GLOBALS['ajax_reload']);
}
/**
* Defines the url to return to in case of error in a sql statement
*/