Merge pull request #18837 from kamil-tekiela/Reduce-globals
Reduce globals
This commit is contained in:
commit
ff03462d65
@ -5651,7 +5651,7 @@ parameters:
|
||||
path: src/Controllers/Table/ChangeController.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#4 \\$currentResult of method PhpMyAdmin\\\\InsertEdit\\:\\:getHtmlForInsertEditRow\\(\\) expects PhpMyAdmin\\\\Dbal\\\\ResultInterface, mixed given\\.$#"
|
||||
message: "#^Parameter \\#4 \\$currentResult of method PhpMyAdmin\\\\InsertEdit\\:\\:getHtmlForInsertEditRow\\(\\) expects PhpMyAdmin\\\\Dbal\\\\ResultInterface, array\\<PhpMyAdmin\\\\Dbal\\\\ResultInterface\\>\\|PhpMyAdmin\\\\Dbal\\\\ResultInterface given\\.$#"
|
||||
count: 1
|
||||
path: src/Controllers/Table/ChangeController.php
|
||||
|
||||
@ -5955,11 +5955,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Controllers/Table/DropColumnController.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access an offset on mixed\\.$#"
|
||||
count: 2
|
||||
path: src/Controllers/Table/ExportController.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset 'back' on mixed\\.$#"
|
||||
count: 1
|
||||
@ -5995,11 +5990,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Controllers/Table/ExportController.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#3 \\$ops of static method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Query\\:\\:replaceClauses\\(\\) expects array\\<int, array\\<int, string\\>\\>, mixed given\\.$#"
|
||||
count: 1
|
||||
path: src/Controllers/Table/ExportController.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#3 \\$table of method PhpMyAdmin\\\\Export\\\\Options\\:\\:getOptions\\(\\) expects string, mixed given\\.$#"
|
||||
count: 1
|
||||
@ -11420,11 +11410,6 @@ parameters:
|
||||
count: 6
|
||||
path: src/Import/Import.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$db of method PhpMyAdmin\\\\Import\\\\Import\\:\\:lookForUse\\(\\) expects string\\|null, mixed given\\.$#"
|
||||
count: 1
|
||||
path: src/Import/Import.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$start of function mb_substr expects int, mixed given\\.$#"
|
||||
count: 1
|
||||
@ -11440,11 +11425,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Import/Import.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#3 \\$reload of method PhpMyAdmin\\\\Import\\\\Import\\:\\:lookForUse\\(\\) expects bool\\|null, mixed given\\.$#"
|
||||
count: 1
|
||||
path: src/Import/Import.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, mixed given\\.$#"
|
||||
count: 1
|
||||
|
||||
@ -901,9 +901,6 @@
|
||||
<DeprecatedMethod>
|
||||
<code>Config::getInstance()</code>
|
||||
</DeprecatedMethod>
|
||||
<InvalidArrayOffset>
|
||||
<code><![CDATA[$GLOBALS['num_cols']]]></code>
|
||||
</InvalidArrayOffset>
|
||||
<MixedArgument>
|
||||
<code>$columnDefault</code>
|
||||
<code>$columnDefault</code>
|
||||
@ -932,7 +929,6 @@
|
||||
</MixedArgumentTypeCoercion>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['message']]]></code>
|
||||
<code><![CDATA[$GLOBALS['num_cols']]]></code>
|
||||
<code>$columnDefault</code>
|
||||
<code>$columnDefault</code>
|
||||
</MixedAssignment>
|
||||
@ -2068,7 +2064,6 @@
|
||||
<code><![CDATA[$GLOBALS['msg']]]></code>
|
||||
<code><![CDATA[$GLOBALS['my_die']]]></code>
|
||||
<code><![CDATA[$GLOBALS['read_multiply']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reset_charset']]]></code>
|
||||
<code><![CDATA[$GLOBALS['result']]]></code>
|
||||
<code><![CDATA[$GLOBALS['run_query']]]></code>
|
||||
@ -2129,10 +2124,8 @@
|
||||
<code><![CDATA[$GLOBALS['max_sql_len']]]></code>
|
||||
<code><![CDATA[$GLOBALS['message_to_show']]]></code>
|
||||
<code><![CDATA[$GLOBALS['msg']]]></code>
|
||||
<code><![CDATA[$GLOBALS['my_die']]]></code>
|
||||
<code><![CDATA[$GLOBALS['noplugin']]]></code>
|
||||
<code><![CDATA[$GLOBALS['read_multiply']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reset_charset']]]></code>
|
||||
<code><![CDATA[$GLOBALS['result']]]></code>
|
||||
<code><![CDATA[$GLOBALS['run_query']]]></code>
|
||||
@ -2387,7 +2380,6 @@
|
||||
</DeprecatedMethod>
|
||||
<InvalidArrayOffset>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['single_table']]]></code>
|
||||
</InvalidArrayOffset>
|
||||
<MixedArgument>
|
||||
@ -2395,7 +2387,6 @@
|
||||
</MixedArgument>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['single_table']]]></code>
|
||||
</MixedAssignment>
|
||||
<PossiblyNullArgument>
|
||||
@ -2416,8 +2407,6 @@
|
||||
<code><![CDATA[$GLOBALS['auto_increment']]]></code>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['message_to_show']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['result']]]></code>
|
||||
</InvalidArrayOffset>
|
||||
<MixedArgumentTypeCoercion>
|
||||
<code>$tableAlters</code>
|
||||
@ -2430,8 +2419,6 @@
|
||||
<code><![CDATA[$GLOBALS['auto_increment']]]></code>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['message_to_show']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['result']]]></code>
|
||||
<code><![CDATA[$GLOBALS['showtable']]]></code>
|
||||
<code><![CDATA[$GLOBALS['showtable']]]></code>
|
||||
<code>$rereadInfo</code>
|
||||
@ -2446,13 +2433,9 @@
|
||||
</DeprecatedMethod>
|
||||
<InvalidArrayOffset>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['result']]]></code>
|
||||
</InvalidArrayOffset>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['result']]]></code>
|
||||
<code>$newname</code>
|
||||
</MixedAssignment>
|
||||
<PossiblyUnusedMethod>
|
||||
@ -2701,7 +2684,6 @@
|
||||
</DeprecatedMethod>
|
||||
<InvalidArrayOffset>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['selected']]]></code>
|
||||
</InvalidArrayOffset>
|
||||
<MixedArgument>
|
||||
@ -2709,7 +2691,6 @@
|
||||
</MixedArgument>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['selected']]]></code>
|
||||
<code>$database</code>
|
||||
</MixedAssignment>
|
||||
@ -3282,7 +3263,6 @@
|
||||
<InvalidArrayOffset>
|
||||
<code><![CDATA[$GLOBALS['active_page']]]></code>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['result']]]></code>
|
||||
</InvalidArrayOffset>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$_POST['field_input_transformation'][$fieldindex]]]></code>
|
||||
@ -3293,7 +3273,6 @@
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['active_page']]]></code>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['result']]]></code>
|
||||
</MixedAssignment>
|
||||
<PossiblyInvalidArgument>
|
||||
<code><![CDATA[$_POST['field_input_transformation'][$fieldindex]]]></code>
|
||||
@ -3324,7 +3303,6 @@
|
||||
<code><![CDATA[$GLOBALS['current_result']]]></code>
|
||||
<code><![CDATA[$GLOBALS['disp_message']]]></code>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['result']]]></code>
|
||||
<code><![CDATA[$GLOBALS['unsaved_values']]]></code>
|
||||
<code><![CDATA[$GLOBALS['where_clause']]]></code>
|
||||
</InvalidArrayOffset>
|
||||
@ -3347,7 +3325,6 @@
|
||||
<code><![CDATA[$GLOBALS['current_result']]]></code>
|
||||
<code><![CDATA[$GLOBALS['disp_message']]]></code>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['result']]]></code>
|
||||
<code><![CDATA[$GLOBALS['unsaved_values']]]></code>
|
||||
<code><![CDATA[$GLOBALS['where_clause']]]></code>
|
||||
<code>$isUpload</code>
|
||||
@ -3501,26 +3478,19 @@
|
||||
<InvalidArrayOffset>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['num_tables']]]></code>
|
||||
<code><![CDATA[$GLOBALS['replaces']]]></code>
|
||||
<code><![CDATA[$GLOBALS['single_table']]]></code>
|
||||
<code><![CDATA[$GLOBALS['unlim_num_rows']]]></code>
|
||||
<code><![CDATA[$GLOBALS['where_clause']]]></code>
|
||||
</InvalidArrayOffset>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$GLOBALS['num_tables']]]></code>
|
||||
<code><![CDATA[$GLOBALS['replaces']]]></code>
|
||||
<code><![CDATA[$GLOBALS['unlim_num_rows']]]></code>
|
||||
</MixedArgument>
|
||||
<MixedArgumentTypeCoercion>
|
||||
<code><![CDATA[$GLOBALS['where_clause']]]></code>
|
||||
</MixedArgumentTypeCoercion>
|
||||
<MixedArrayAssignment>
|
||||
<code><![CDATA[$GLOBALS['replaces'][]]]></code>
|
||||
<code><![CDATA[$GLOBALS['replaces'][]]]></code>
|
||||
</MixedArrayAssignment>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code><![CDATA[$GLOBALS['replaces']]]></code>
|
||||
<code><![CDATA[$GLOBALS['single_table']]]></code>
|
||||
<code><![CDATA[$GLOBALS['unlim_num_rows']]]></code>
|
||||
<code><![CDATA[$GLOBALS['where_clause']]]></code>
|
||||
@ -3920,12 +3890,6 @@
|
||||
</MixedArgumentTypeCoercion>
|
||||
</file>
|
||||
<file src="src/Controllers/Table/Structure/AddKeyController.php">
|
||||
<InvalidArrayOffset>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
</InvalidArrayOffset>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
</MixedAssignment>
|
||||
<PossiblyUnusedMethod>
|
||||
<code>__construct</code>
|
||||
</PossiblyUnusedMethod>
|
||||
@ -6722,7 +6686,6 @@
|
||||
<code><![CDATA[$GLOBALS['msg']]]></code>
|
||||
<code><![CDATA[$GLOBALS['my_die']]]></code>
|
||||
<code><![CDATA[$GLOBALS['read_multiply']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['run_query']]]></code>
|
||||
<code><![CDATA[$GLOBALS['skip_queries']]]></code>
|
||||
<code><![CDATA[$GLOBALS['sql_query_disabled']]]></code>
|
||||
@ -6733,7 +6696,6 @@
|
||||
</InvalidArrayOffset>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$GLOBALS['charset_of_file']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code>$active</code>
|
||||
<code>$additionalSql[$i]</code>
|
||||
<code>$size</code>
|
||||
@ -6829,7 +6791,6 @@
|
||||
<code><![CDATA[$GLOBALS['offset']]]></code>
|
||||
<code><![CDATA[$GLOBALS['read_multiply']]]></code>
|
||||
<code><![CDATA[$GLOBALS['read_multiply']]]></code>
|
||||
<code><![CDATA[$GLOBALS['reload']]]></code>
|
||||
<code><![CDATA[$GLOBALS['run_query']]]></code>
|
||||
<code><![CDATA[$GLOBALS['skip_queries']]]></code>
|
||||
<code><![CDATA[$GLOBALS['skip_queries']]]></code>
|
||||
@ -6903,6 +6864,9 @@
|
||||
<code><![CDATA[$GLOBALS['read_multiply']]]></code>
|
||||
<code><![CDATA[$GLOBALS['timestamp']]]></code>
|
||||
</PossiblyNullOperand>
|
||||
<RedundantCondition>
|
||||
<code><![CDATA[$GLOBALS['result'] == false]]></code>
|
||||
</RedundantCondition>
|
||||
</file>
|
||||
<file src="src/Index.php">
|
||||
<DeprecatedMethod>
|
||||
|
||||
@ -35,7 +35,6 @@ class CentralColumnsController extends AbstractController
|
||||
public function __invoke(ServerRequest $request): void
|
||||
{
|
||||
$GLOBALS['message'] ??= null;
|
||||
$GLOBALS['num_cols'] ??= null;
|
||||
|
||||
if ($request->hasBodyParam('edit_save')) {
|
||||
$this->response->addHTML((string) $this->editSave([
|
||||
@ -135,13 +134,13 @@ class CentralColumnsController extends AbstractController
|
||||
$pos = (int) $request->getParsedBodyParam('pos');
|
||||
}
|
||||
|
||||
$GLOBALS['num_cols'] = $this->centralColumns->getColumnsCount(
|
||||
$numberOfColumns = $this->centralColumns->getColumnsCount(
|
||||
$GLOBALS['db'],
|
||||
$pos,
|
||||
Config::getInstance()->settings['MaxRows'],
|
||||
);
|
||||
$GLOBALS['message'] = Message::success(
|
||||
sprintf(__('Showing rows %1$s - %2$s.'), $pos + 1, $pos + $GLOBALS['num_cols']),
|
||||
sprintf(__('Showing rows %1$s - %2$s.'), $pos + 1, $pos + $numberOfColumns),
|
||||
);
|
||||
if (! isset($tmpMsg) || $tmpMsg === true) {
|
||||
return;
|
||||
|
||||
@ -94,9 +94,7 @@ final class ImportController extends AbstractController
|
||||
$GLOBALS['import_file_name'] ??= null;
|
||||
$GLOBALS['import_notice'] ??= null;
|
||||
$GLOBALS['read_multiply'] ??= null;
|
||||
$GLOBALS['my_die'] ??= null;
|
||||
$GLOBALS['active_page'] ??= null;
|
||||
$GLOBALS['reload'] ??= null;
|
||||
|
||||
$GLOBALS['charset_of_file'] = $request->getParsedBodyParam('charset_of_file');
|
||||
$GLOBALS['format'] = $request->getParsedBodyParam('format', '');
|
||||
|
||||
@ -52,7 +52,6 @@ class DatabaseController extends AbstractController
|
||||
$GLOBALS['server'] ??= null;
|
||||
$GLOBALS['message'] ??= null;
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
$GLOBALS['reload'] ??= null;
|
||||
$GLOBALS['urlParams'] ??= null;
|
||||
$GLOBALS['single_table'] ??= null;
|
||||
|
||||
|
||||
@ -57,8 +57,6 @@ class TableController extends AbstractController
|
||||
{
|
||||
$GLOBALS['urlParams'] ??= null;
|
||||
$GLOBALS['auto_increment'] ??= null;
|
||||
$GLOBALS['reload'] ??= null;
|
||||
$GLOBALS['result'] ??= null;
|
||||
$GLOBALS['message_to_show'] ??= null;
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
|
||||
@ -213,13 +211,13 @@ class TableController extends AbstractController
|
||||
$GLOBALS['db'] = $oldDb;
|
||||
$this->dbi->selectDb($oldDb);
|
||||
$newMessage .= $pmaTable->getLastMessage();
|
||||
$GLOBALS['result'] = true;
|
||||
$result = true;
|
||||
$GLOBALS['table'] = $pmaTable->getName();
|
||||
$rereadInfo = true;
|
||||
$GLOBALS['reload'] = true;
|
||||
} else {
|
||||
$newMessage .= $pmaTable->getLastError();
|
||||
$GLOBALS['result'] = false;
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,7 +256,8 @@ class TableController extends AbstractController
|
||||
. Util::backquote($GLOBALS['table']);
|
||||
$GLOBALS['sql_query'] .= "\r\n" . implode("\r\n", $tableAlters);
|
||||
$GLOBALS['sql_query'] .= ';';
|
||||
$GLOBALS['result'] = (bool) $this->dbi->query($GLOBALS['sql_query']);
|
||||
$this->dbi->query($GLOBALS['sql_query']);
|
||||
$result = true;
|
||||
$rereadInfo = true;
|
||||
$warningMessages = $this->operations->getWarningMessagesArray();
|
||||
}
|
||||
@ -299,7 +298,8 @@ class TableController extends AbstractController
|
||||
urldecode($orderField),
|
||||
is_string($orderOrder) ? $orderOrder : '',
|
||||
);
|
||||
$GLOBALS['result'] = $this->dbi->query($GLOBALS['sql_query']);
|
||||
$this->dbi->query($GLOBALS['sql_query']);
|
||||
$result = true;
|
||||
}
|
||||
|
||||
/** @var mixed $partitionOperation */
|
||||
@ -318,7 +318,8 @@ class TableController extends AbstractController
|
||||
$partitionOperation,
|
||||
is_array($partitionNames) ? $partitionNames : [],
|
||||
);
|
||||
$GLOBALS['result'] = $this->dbi->query($GLOBALS['sql_query']);
|
||||
$this->dbi->query($GLOBALS['sql_query']);
|
||||
$result = true;
|
||||
}
|
||||
|
||||
if ($rereadInfo) {
|
||||
@ -342,12 +343,12 @@ class TableController extends AbstractController
|
||||
$createOptions = $pmaTable->getCreateOptions();
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['result']) && empty($GLOBALS['message_to_show'])) {
|
||||
if (isset($result) && empty($GLOBALS['message_to_show'])) {
|
||||
if ($newMessage === '') {
|
||||
if (empty($GLOBALS['sql_query'])) {
|
||||
$newMessage = Message::success(__('No change'));
|
||||
} else {
|
||||
$newMessage = $GLOBALS['result']
|
||||
$newMessage = $result
|
||||
? Message::success()
|
||||
: Message::error();
|
||||
}
|
||||
@ -365,7 +366,7 @@ class TableController extends AbstractController
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$newMessage = $GLOBALS['result']
|
||||
$newMessage = $result
|
||||
? Message::success($newMessage)
|
||||
: Message::error($newMessage);
|
||||
}
|
||||
|
||||
@ -40,8 +40,6 @@ class ViewController extends AbstractController
|
||||
public function __invoke(ServerRequest $request): void
|
||||
{
|
||||
$GLOBALS['urlParams'] ??= null;
|
||||
$GLOBALS['reload'] ??= null;
|
||||
$GLOBALS['result'] ??= null;
|
||||
$tableObject = $this->dbi->getTable($GLOBALS['db'], $GLOBALS['table']);
|
||||
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
@ -96,24 +94,24 @@ class ViewController extends AbstractController
|
||||
if ($request->hasBodyParam('submitoptions')) {
|
||||
if (is_string($newname) && $tableObject->rename($newname)) {
|
||||
$message->addText($tableObject->getLastMessage());
|
||||
$GLOBALS['result'] = true;
|
||||
$result = true;
|
||||
$GLOBALS['table'] = $tableObject->getName();
|
||||
/* Force reread after rename */
|
||||
$tableObject->getStatusInfo(null, true);
|
||||
$GLOBALS['reload'] = true;
|
||||
} else {
|
||||
$message->addText($tableObject->getLastError());
|
||||
$GLOBALS['result'] = false;
|
||||
$message->addText($tableObject->getLastError());
|
||||
$result = false;
|
||||
}
|
||||
|
||||
$warningMessages = $this->operations->getWarningMessagesArray();
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['result'])) {
|
||||
if (isset($result)) {
|
||||
// set to success by default, because result set could be empty
|
||||
// (for example, a table rename)
|
||||
if ($message->getString() === '') {
|
||||
if ($GLOBALS['result']) {
|
||||
if ($result) {
|
||||
$message->addText(
|
||||
__('Your SQL query has been executed successfully.'),
|
||||
);
|
||||
@ -121,8 +119,7 @@ class ViewController extends AbstractController
|
||||
$message->addText(__('Error'));
|
||||
}
|
||||
|
||||
// $result should exist, regardless of $_message
|
||||
$type = $GLOBALS['result'] ? 'success' : 'error';
|
||||
$type = $result ? 'success' : 'error';
|
||||
}
|
||||
|
||||
if ($warningMessages !== []) {
|
||||
|
||||
@ -37,7 +37,6 @@ final class DestroyController extends AbstractController
|
||||
{
|
||||
$GLOBALS['selected'] ??= null;
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
$GLOBALS['reload'] ??= null;
|
||||
|
||||
$selectedDbs = $request->getParsedBodyParam('selected_dbs');
|
||||
|
||||
|
||||
@ -50,7 +50,6 @@ class AddFieldController extends AbstractController
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
$GLOBALS['message'] ??= null;
|
||||
$GLOBALS['active_page'] ??= null;
|
||||
$GLOBALS['result'] ??= null;
|
||||
|
||||
/** @var string|null $numberOfFields */
|
||||
$numberOfFields = $request->getParsedBodyParam('num_fields');
|
||||
@ -91,13 +90,13 @@ class AddFieldController extends AbstractController
|
||||
return;
|
||||
}
|
||||
|
||||
$GLOBALS['result'] = $createAddField->tryColumnCreationQuery(
|
||||
$result = $createAddField->tryColumnCreationQuery(
|
||||
DatabaseName::from($GLOBALS['db']),
|
||||
$GLOBALS['sql_query'],
|
||||
$GLOBALS['errorUrl'],
|
||||
);
|
||||
|
||||
if (! $GLOBALS['result']) {
|
||||
if (! $result) {
|
||||
$errorMessageHtml = Generator::mysqlDie('', '', false, $GLOBALS['errorUrl'], false);
|
||||
$this->response->addHTML($errorMessageHtml ?? '');
|
||||
$this->response->setRequestStatus(false);
|
||||
|
||||
@ -56,7 +56,6 @@ class ChangeController extends AbstractController
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
$GLOBALS['where_clause'] ??= null;
|
||||
$GLOBALS['unsaved_values'] ??= null;
|
||||
$GLOBALS['result'] ??= null;
|
||||
$GLOBALS['current_result'] ??= null;
|
||||
|
||||
$this->pageSettings->init('Edit');
|
||||
@ -108,7 +107,7 @@ class ChangeController extends AbstractController
|
||||
$GLOBALS['where_clause'],
|
||||
$whereClauseArray,
|
||||
$whereClauses,
|
||||
$GLOBALS['result'],
|
||||
$result,
|
||||
$rows,
|
||||
$foundUniqueIndex,
|
||||
$afterInsert,
|
||||
@ -231,10 +230,9 @@ class ChangeController extends AbstractController
|
||||
|
||||
$GLOBALS['plugin_scripts'] = [];
|
||||
foreach ($rows as $rowId => $currentRow) {
|
||||
$GLOBALS['current_result'] = (isset($GLOBALS['result'])
|
||||
&& is_array($GLOBALS['result']) && isset($GLOBALS['result'][$rowId])
|
||||
? $GLOBALS['result'][$rowId]
|
||||
: $GLOBALS['result']);
|
||||
$GLOBALS['current_result'] = is_array($result) && isset($result[$rowId])
|
||||
? $result[$rowId]
|
||||
: $result;
|
||||
$repopulate = [];
|
||||
$checked = true;
|
||||
if (isset($GLOBALS['unsaved_values'][$rowId])) {
|
||||
|
||||
@ -38,7 +38,6 @@ class ExportController extends AbstractController
|
||||
public function __invoke(ServerRequest $request): void
|
||||
{
|
||||
$GLOBALS['urlParams'] ??= null;
|
||||
$GLOBALS['replaces'] ??= null;
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
$GLOBALS['where_clause'] ??= null;
|
||||
$GLOBALS['unlim_num_rows'] ??= null;
|
||||
@ -71,19 +70,16 @@ class ExportController extends AbstractController
|
||||
|
||||
if (! empty($parser->statements[0]) && ($parser->statements[0] instanceof SelectStatement)) {
|
||||
// Checking if the WHERE clause has to be replaced.
|
||||
$replaces = [];
|
||||
if (! empty($GLOBALS['where_clause']) && is_array($GLOBALS['where_clause'])) {
|
||||
$GLOBALS['replaces'][] = ['WHERE', 'WHERE (' . implode(') OR (', $GLOBALS['where_clause']) . ')'];
|
||||
$replaces[] = ['WHERE', 'WHERE (' . implode(') OR (', $GLOBALS['where_clause']) . ')'];
|
||||
}
|
||||
|
||||
// Preparing to remove the LIMIT clause.
|
||||
$GLOBALS['replaces'][] = ['LIMIT', ''];
|
||||
$replaces[] = ['LIMIT', ''];
|
||||
|
||||
// Replacing the clauses.
|
||||
$GLOBALS['sql_query'] = Query::replaceClauses(
|
||||
$parser->statements[0],
|
||||
$parser->list,
|
||||
$GLOBALS['replaces'],
|
||||
);
|
||||
$GLOBALS['sql_query'] = Query::replaceClauses($parser->statements[0], $parser->list, $replaces);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,8 +24,6 @@ final class AddKeyController extends AbstractController
|
||||
|
||||
public function __invoke(ServerRequest $request): void
|
||||
{
|
||||
$GLOBALS['reload'] ??= null;
|
||||
|
||||
($this->sqlController)($request);
|
||||
|
||||
$GLOBALS['reload'] = true;
|
||||
|
||||
@ -127,9 +127,7 @@ class Import
|
||||
*/
|
||||
public function executeQuery(string $sql, array &$sqlData): void
|
||||
{
|
||||
$GLOBALS['my_die'] ??= null;
|
||||
$GLOBALS['error'] ??= null;
|
||||
$GLOBALS['reload'] ??= null;
|
||||
$GLOBALS['msg'] ??= null;
|
||||
$GLOBALS['sql_query_disabled'] ??= null;
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
@ -141,10 +139,7 @@ class Import
|
||||
|
||||
$GLOBALS['msg'] = '# ';
|
||||
if ($GLOBALS['result'] === false) { // execution failed
|
||||
if (! isset($GLOBALS['my_die'])) {
|
||||
$GLOBALS['my_die'] = [];
|
||||
}
|
||||
|
||||
$GLOBALS['my_die'] ??= [];
|
||||
$GLOBALS['my_die'][] = ['sql' => $sql, 'error' => $dbi->getError()];
|
||||
|
||||
$GLOBALS['msg'] .= __('Error');
|
||||
@ -178,7 +173,11 @@ class Import
|
||||
// If a 'USE <db>' SQL-clause was found and the query
|
||||
// succeeded, set our current $db to the new one
|
||||
if ($GLOBALS['result'] != false) {
|
||||
[$GLOBALS['db'], $GLOBALS['reload']] = $this->lookForUse($sql, $GLOBALS['db'], $GLOBALS['reload']);
|
||||
$dbNameInsideUse = $this->lookForUse($sql);
|
||||
if ($dbNameInsideUse !== '') {
|
||||
$GLOBALS['db'] = $dbNameInsideUse;
|
||||
$GLOBALS['reload'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$pattern = '@^[\s]*(DROP|CREATE)[\s]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@im';
|
||||
@ -290,28 +289,20 @@ class Import
|
||||
|
||||
/**
|
||||
* Looks for the presence of USE to possibly change current db
|
||||
*
|
||||
* @param string|null $buffer buffer to examine
|
||||
* @param string|null $db current db
|
||||
* @param bool|null $reload reload
|
||||
*
|
||||
* @return mixed[] (current or new db, whether to reload)
|
||||
*/
|
||||
public function lookForUse(string|null $buffer, string|null $db, bool|null $reload): array
|
||||
public function lookForUse(string $buffer): string
|
||||
{
|
||||
if (preg_match('@^[\s]*USE[[:space:]]+([\S]+)@i', (string) $buffer, $match)) {
|
||||
if (preg_match('@^[\s]*USE[[:space:]]+([\S]+)@i', $buffer, $match)) {
|
||||
$db = trim($match[1]);
|
||||
$db = trim($db, ';'); // for example, USE abc;
|
||||
|
||||
// $db must not contain the escape characters generated by backquote()
|
||||
// ( used in buildSql() as: backquote($db_name), and then called
|
||||
// in runQuery() which in turn calls lookForUse() )
|
||||
$db = Util::unQuote($db);
|
||||
|
||||
$reload = true;
|
||||
return Util::unQuote($db);
|
||||
}
|
||||
|
||||
return [$db, $reload];
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -86,38 +86,18 @@ class ImportTest extends AbstractTestCase
|
||||
public function testLookForUse(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
[null, null],
|
||||
$this->import->lookForUse(null, null, null),
|
||||
'',
|
||||
$this->import->lookForUse('select 1 from myTable'),
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
['myDb', null],
|
||||
$this->import->lookForUse(null, 'myDb', null),
|
||||
'anotherDb',
|
||||
$this->import->lookForUse('use anotherDb'),
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
['myDb', true],
|
||||
$this->import->lookForUse(null, 'myDb', true),
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
['myDb', true],
|
||||
$this->import->lookForUse('select 1 from myTable', 'myDb', true),
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
['anotherDb', true],
|
||||
$this->import->lookForUse('use anotherDb', 'myDb', false),
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
['anotherDb', true],
|
||||
$this->import->lookForUse('use anotherDb', 'myDb', true),
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
['anotherDb', true],
|
||||
$this->import->lookForUse('use `anotherDb`;', 'myDb', true),
|
||||
'anotherDb',
|
||||
$this->import->lookForUse('use `anotherDb`;'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user