Merge pull request #19482 from kamil-tekiela/GLOBALS-query

Remove $GLOBALS['query']
This commit is contained in:
Maurício Meneghini Fauth 2025-01-02 16:05:01 -03:00 committed by GitHub
commit 358e9a1466
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 12 additions and 57 deletions

View File

@ -4596,7 +4596,7 @@ parameters:
-
message: '#^Cannot access an offset on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 2
count: 1
path: src/Controllers/Table/ReplaceController.php
-
@ -4626,7 +4626,7 @@ parameters:
-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
identifier: empty.notAllowed
count: 8
count: 7
path: src/Controllers/Table/ReplaceController.php
-
@ -4683,18 +4683,6 @@ parameters:
count: 1
path: src/Controllers/Table/ReplaceController.php
-
message: '#^Parameter \#1 \$query of method PhpMyAdmin\\InsertEdit\:\:executeSqlQuery\(\) expects array\<mixed\>, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Table/ReplaceController.php
-
message: '#^Parameter \#1 \$queryData of static method PhpMyAdmin\\Core\:\:previewSQL\(\) expects array\<mixed\>\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Table/ReplaceController.php
-
message: '#^Parameter \#2 \$relationField of method PhpMyAdmin\\InsertEdit\:\:getLinkForRelationalDisplayField\(\) expects string, \(int\|string\) given\.$#'
identifier: argument.type
@ -5613,12 +5601,6 @@ parameters:
count: 1
path: src/Core.php
-
message: '#^Parameter \#1 \$sqlQuery of static method PhpMyAdmin\\Html\\Generator\:\:formatSql\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Core.php
-
message: '#^Parameter \#1 \$value of function count expects array\|Countable, mixed given\.$#'
identifier: argument.type
@ -9768,18 +9750,6 @@ parameters:
count: 1
path: src/InsertEdit.php
-
message: '#^Parameter \#1 \$query of method PhpMyAdmin\\Dbal\\DatabaseInterface\:\:query\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/InsertEdit.php
-
message: '#^Parameter \#1 \$query of method PhpMyAdmin\\Dbal\\DatabaseInterface\:\:tryQuery\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/InsertEdit.php
-
message: '#^Parameter \#1 \$sqlQuery of static method PhpMyAdmin\\Core\:\:checkSqlQuerySignature\(\) expects string, mixed given\.$#'
identifier: argument.type

View File

@ -1890,9 +1890,6 @@
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['query']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$configuration['ThemeDefault']]]></code>
<code><![CDATA[$configuration['ThemeDefault']]]></code>
@ -1901,7 +1898,6 @@
<code><![CDATA[$key]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$GLOBALS['query']]]></code>
<code><![CDATA[$_POST[str_replace('/', '-', (string) $k)]]]></code>
<code><![CDATA[$configuration]]></code>
<code><![CDATA[$redirectParams['lang']]]></code>
@ -2932,7 +2928,6 @@
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['disp_message']]]></code>
<code><![CDATA[$GLOBALS['disp_query']]]></code>
<code><![CDATA[$GLOBALS['query']]]></code>
<code><![CDATA[$GLOBALS['unsaved_values']]]></code>
</InvalidArrayOffset>
<InvalidPropertyAssignmentValue>
@ -2975,7 +2970,6 @@
<MixedAssignment>
<code><![CDATA[$GLOBALS['disp_message']]]></code>
<code><![CDATA[$GLOBALS['disp_query']]]></code>
<code><![CDATA[$GLOBALS['query']]]></code>
<code><![CDATA[$GLOBALS['unsaved_values']]]></code>
<code><![CDATA[$GLOBALS['unsaved_values'][$rowNumber]]]></code>
<code><![CDATA[$clauseIsUnique]]></code>
@ -3016,7 +3010,6 @@
<code><![CDATA[Response]]></code>
</PossiblyUnusedReturnValue>
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty($GLOBALS['query'])]]></code>
<code><![CDATA[empty($mimeMap[$columnName]['input_transformation'])]]></code>
</RiskyTruthyFalsyComparison>
</file>
@ -3522,7 +3515,6 @@
</InvalidOperand>
<MixedArgument>
<code><![CDATA[$path[$depth + 1]]]></code>
<code><![CDATA[$query]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$a[$key]]]></code>
@ -3541,7 +3533,6 @@
<code><![CDATA[$a[$lastKey]]]></code>
<code><![CDATA[$parsedBody[$urlQueryParamKey]]]></code>
<code><![CDATA[$path[$depth]]]></code>
<code><![CDATA[$query]]></code>
<code><![CDATA[$queryParams[$urlQueryParamKey]]]></code>
<code><![CDATA[$secret]]></code>
<code><![CDATA[$secret]]></code>
@ -5756,12 +5747,9 @@
<code><![CDATA[$foreigner['foreign_table']]]></code>
<code><![CDATA[$foreigner['foreign_table']]]></code>
<code><![CDATA[$rows[$keyId]]]></code>
<code><![CDATA[$singleQuery]]></code>
<code><![CDATA[$singleQuery]]></code>
<code><![CDATA[$transformation[$type . '_options'] ?? '']]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$query]]></code>
<code><![CDATA[$thisUrlParams]]></code>
<code><![CDATA[$thisUrlParams]]></code>
<code><![CDATA[$whereClauseArray]]></code>
@ -5789,7 +5777,6 @@
<code><![CDATA[$isUnsigned]]></code>
<code><![CDATA[$maxlength]]></code>
<code><![CDATA[$maxlength]]></code>
<code><![CDATA[$singleQuery]]></code>
<code><![CDATA[$specialChars]]></code>
<code><![CDATA[$whereClause]]></code>
</MixedAssignment>

View File

@ -60,7 +60,6 @@ final class ManageController implements InvocableController
public function __invoke(ServerRequest $request): Response
{
$GLOBALS['error'] ??= null;
$GLOBALS['query'] ??= null;
$route = $request->getRoute();
@ -202,10 +201,10 @@ final class ManageController implements InvocableController
$result = $this->userPreferences->save($configFile->getConfigArray());
if ($result === true) {
if ($returnUrl !== null && $returnUrl !== '') {
$GLOBALS['query'] = Util::splitURLQuery($returnUrl);
$query = Util::splitURLQuery($returnUrl);
$returnUrl = parse_url($returnUrl, PHP_URL_PATH);
foreach ($GLOBALS['query'] as $q) {
foreach ($query as $q) {
$pos = mb_strpos($q, '=');
$k = mb_substr($q, 0, (int) $pos);
if ($k === 'token') {

View File

@ -73,7 +73,6 @@ final class ReplaceController implements InvocableController
$GLOBALS['unsaved_values'] ??= null;
$GLOBALS['disp_query'] ??= null;
$GLOBALS['disp_message'] ??= null;
$GLOBALS['query'] ??= null;
$this->dbi->selectDb(Current::$database);
@ -103,7 +102,7 @@ final class ReplaceController implements InvocableController
$isInsertignore = $request->getParsedBodyParam('submit_type') === 'insertignore';
$GLOBALS['query'] = [];
$query = [];
$valueSets = [];
$mimeMap = $this->transformations->getMime(Current::$database, Current::$table) ?? [];
@ -255,7 +254,7 @@ final class ReplaceController implements InvocableController
} else {
// build update query
$clauseIsUnique = $request->getParam('clause_is_unique', '');// Should contain 0 or 1
$GLOBALS['query'][] = 'UPDATE ' . Util::backquote(Current::$table)
$query[] = 'UPDATE ' . Util::backquote(Current::$table)
. ' SET ' . implode(', ', $queryValues)
. ' WHERE ' . $whereClause
. ($clauseIsUnique ? '' : ' LIMIT 1');
@ -279,13 +278,13 @@ final class ReplaceController implements InvocableController
// Builds the sql query
if ($isInsert && $valueSets !== []) {
$GLOBALS['query'] = (array) QueryGenerator::buildInsertSqlQuery(
$query = (array) QueryGenerator::buildInsertSqlQuery(
Current::$table,
$isInsertignore,
$queryFields,
$valueSets,
);
} elseif (empty($GLOBALS['query']) && ! $request->hasBodyParam('preview_sql') && ! $rowSkipped) {
} elseif ($query === [] && ! $request->hasBodyParam('preview_sql') && ! $rowSkipped) {
// No change -> move back to the calling script
//
// Note: logic passes here for inline edit
@ -300,7 +299,7 @@ final class ReplaceController implements InvocableController
// If there is a request for SQL previewing.
if ($request->hasBodyParam('preview_sql')) {
Core::previewSQL($GLOBALS['query']);
Core::previewSQL($query);
return $this->response->response();
}
@ -320,7 +319,7 @@ final class ReplaceController implements InvocableController
$lastMessages,
$warningMessages,
$errorMessages,
] = $this->insertEdit->executeSqlQuery($GLOBALS['query']);
] = $this->insertEdit->executeSqlQuery($query);
if ($isInsert && ($valueSets !== [] || $rowSkipped)) {
Current::$message = Message::getMessageForInsertedRows($totalAffectedRows);

View File

@ -490,7 +490,7 @@ class Core
/**
* Displays SQL query before executing.
*
* @param mixed[]|string $queryData Array containing queries or query itself
* @param string[]|string $queryData Array containing queries or query itself
*/
public static function previewSQL(array|string $queryData): void
{

View File

@ -903,7 +903,7 @@ class InsertEdit
/**
* Executes the sql query and get the result, then move back to the calling page
*
* @param mixed[] $query built query from buildSqlQuery()
* @param string[] $query built query from buildSqlQuery()
*
* @return array{int, Message[], string[], string[]}
*/