Skip to content

Commit

Permalink
Merge pull request phpmyadmin#19450 from kamil-tekiela/Removal-of-som…
Browse files Browse the repository at this point in the history
…e-dead-GLOBALS

Removal of some dead globals
  • Loading branch information
MauricioFauth authored Dec 17, 2024
2 parents 7f5cd05 + 873a743 commit ddc64a4
Show file tree
Hide file tree
Showing 20 changed files with 28 additions and 161 deletions.
26 changes: 1 addition & 25 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3561,12 +3561,6 @@ parameters:
count: 1
path: src/Controllers/Server/DatabasesController.php

-
message: '#^Parameter \#1 \$tmpSelect of method PhpMyAdmin\\Export\\Options\:\:getDatabasesForSelectOptions\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Server/ExportController.php

-
message: '#^Parameter \#5 \$numTables of method PhpMyAdmin\\Export\\Options\:\:getOptions\(\) expects int\|string, mixed given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -11784,12 +11778,6 @@ parameters:
count: 1
path: src/Plugins/Auth/AuthenticationHttp.php

-
message: '#^Property PhpMyAdmin\\Plugins\\AuthenticationPlugin\:\:\$user \(string\) does not accept mixed\.$#'
identifier: assign.propertyType
count: 1
path: src/Plugins/Auth/AuthenticationHttp.php

-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
Expand Down Expand Up @@ -15606,7 +15594,7 @@ parameters:
-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
identifier: empty.notAllowed
count: 3
count: 2
path: src/ResponseRenderer.php

-
Expand Down Expand Up @@ -17121,12 +17109,6 @@ parameters:
count: 2
path: src/Table/ColumnsDefinition.php

-
message: '#^Cannot access offset mixed on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: src/Table/ColumnsDefinition.php

-
message: '#^Cannot cast mixed to string\.$#'
identifier: cast.string
Expand Down Expand Up @@ -17181,12 +17163,6 @@ parameters:
count: 1
path: src/Table/ColumnsDefinition.php

-
message: '#^Parameter \#1 \.\.\.\$arrays of function array_merge expects array, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Table/ColumnsDefinition.php

-
message: '#^Parameter \#2 \$string of function explode expects string, mixed given\.$#'
identifier: argument.type
Expand Down
71 changes: 2 additions & 69 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,6 @@
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['language_stats']]]></code>
<code><![CDATA[$GLOBALS['language_stats']]]></code>
<code><![CDATA[$GLOBALS['show_query']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$this->config->get('ShowGitRevision') ?? true]]></code>
Expand All @@ -1635,9 +1634,6 @@
<MixedArrayTypeCoercion>
<code><![CDATA[$config->settings['Servers'][Current::$server]]]></code>
</MixedArrayTypeCoercion>
<MixedAssignment>
<code><![CDATA[$GLOBALS['show_query']]]></code>
</MixedAssignment>
<PossiblyNullArgument>
<code><![CDATA[$this->config->get('TempDir')]]></code>
</PossiblyNullArgument>
Expand Down Expand Up @@ -1944,12 +1940,6 @@
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['hash']]]></code>
</InvalidArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['hash']]]></code>
</MixedAssignment>
<PossiblyUnusedMethod>
<code><![CDATA[__construct]]></code>
</PossiblyUnusedMethod>
Expand All @@ -1958,12 +1948,6 @@
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['hash']]]></code>
</InvalidArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['hash']]]></code>
</MixedAssignment>
<PossiblyUnusedMethod>
<code><![CDATA[__construct]]></code>
</PossiblyUnusedMethod>
Expand All @@ -1972,12 +1956,6 @@
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['hash']]]></code>
</InvalidArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['hash']]]></code>
</MixedAssignment>
<PossiblyUnusedMethod>
<code><![CDATA[__construct]]></code>
</PossiblyUnusedMethod>
Expand All @@ -1986,12 +1964,6 @@
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['hash']]]></code>
</InvalidArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['hash']]]></code>
</MixedAssignment>
<PossiblyUnusedMethod>
<code><![CDATA[__construct]]></code>
</PossiblyUnusedMethod>
Expand Down Expand Up @@ -2053,12 +2025,6 @@
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['hash']]]></code>
</InvalidArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['hash']]]></code>
</MixedAssignment>
<PossiblyUnusedMethod>
<code><![CDATA[__construct]]></code>
</PossiblyUnusedMethod>
Expand All @@ -2067,12 +2033,6 @@
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['hash']]]></code>
</InvalidArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['hash']]]></code>
</MixedAssignment>
<PossiblyUnusedMethod>
<code><![CDATA[__construct]]></code>
</PossiblyUnusedMethod>
Expand Down Expand Up @@ -2183,21 +2143,15 @@
<file src="src/Controllers/Server/ExportController.php">
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['num_tables']]]></code>
<code><![CDATA[$GLOBALS['select_item']]]></code>
<code><![CDATA[$GLOBALS['single_table']]]></code>
<code><![CDATA[$GLOBALS['tmp_select']]]></code>
<code><![CDATA[$GLOBALS['unlim_num_rows']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$GLOBALS['num_tables']]]></code>
<code><![CDATA[$GLOBALS['select_item']]]></code>
<code><![CDATA[$GLOBALS['unlim_num_rows']]]></code>
</MixedArgument>
<MixedAssignment>
<code><![CDATA[$GLOBALS['select_item']]]></code>
<code><![CDATA[$GLOBALS['select_item']]]></code>
<code><![CDATA[$GLOBALS['single_table']]]></code>
<code><![CDATA[$GLOBALS['tmp_select']]]></code>
<code><![CDATA[$GLOBALS['unlim_num_rows']]]></code>
</MixedAssignment>
<PossiblyUnusedMethod>
Expand Down Expand Up @@ -3661,15 +3615,9 @@
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['change_password_message']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$message->getDisplay()]]></code>
</MixedArgument>
<MixedAssignment>
<code><![CDATA[$GLOBALS['change_password_message']]]></code>
</MixedAssignment>
<MixedMethodCall>
<code><![CDATA[getDisplay]]></code>
</MixedMethodCall>
Expand Down Expand Up @@ -6902,14 +6850,9 @@
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['PHP_AUTH_PW']]]></code>
<code><![CDATA[$GLOBALS['PHP_AUTH_USER']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$this->user]]></code>
</MixedArgument>
<MixedAssignment>
<code><![CDATA[$this->password]]></code>
<code><![CDATA[$this->user]]></code>
</MixedAssignment>
<PossiblyInvalidArgument>
<code><![CDATA[$oldUser]]></code>
Expand Down Expand Up @@ -9205,7 +9148,6 @@
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['focus_querywindow']]]></code>
<code><![CDATA[$GLOBALS['reload']]]></code>
</InvalidArrayOffset>
<MixedArgumentTypeCoercion>
Expand Down Expand Up @@ -9970,11 +9912,7 @@
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['mime_map']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$GLOBALS['mime_map'][$columnMeta['Field']] ?? []]]></code>
<code><![CDATA[$columnMeta['Default']]]></code>
<code><![CDATA[$columnMeta['DefaultValue']]]></code>
<code><![CDATA[$columnMeta['Field']]]></code>
Expand All @@ -9986,20 +9924,15 @@
<code><![CDATA[Util::getValueByKey($_POST, ['field_key', $columnNumber], '')]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$GLOBALS['mime_map'][$columnMeta['Field']]]]></code>
<code><![CDATA[$columnMeta['column_status']['isEditable']]]></code>
<code><![CDATA[$columnMeta['column_status']['isEditable']]]></code>
</MixedArrayAccess>
<MixedArrayAssignment>
<code><![CDATA[$GLOBALS['mime_map'][$columnMeta['Field']]]]></code>
</MixedArrayAssignment>
<MixedArrayOffset>
<code><![CDATA[$GLOBALS['mime_map'][$columnMeta['Field']]]]></code>
<code><![CDATA[$GLOBALS['mime_map'][$columnMeta['Field']]]]></code>
<code><![CDATA[$commentsMap[$columnMeta['Field']]]]></code>
<code><![CDATA[$mimeMap[$columnMeta['Field']]]]></code>
<code><![CDATA[$mimeMap[$columnMeta['Field']]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['mime_map']]]></code>
<code><![CDATA[$columnMeta['Default']]]></code>
<code><![CDATA[$columnMeta['Expression']]]></code>
<code><![CDATA[$commentsMap[$columnMeta['Field']]]]></code>
Expand Down
2 changes: 0 additions & 2 deletions src/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public function __invoke(ServerRequest $request): Response
}

$GLOBALS['message'] ??= null;
$GLOBALS['show_query'] ??= null;

if ($request->isAjax() && ! empty($_REQUEST['access_time'])) {
return $this->response->response();
Expand All @@ -79,7 +78,6 @@ public function __invoke(ServerRequest $request): Response
// The DB is defined here and sent to the JS front-end to refresh the DB tree
Current::$database = $request->getParsedBodyParamAsString('db', '');
Current::$table = '';
$GLOBALS['show_query'] = '1';

if (Current::$server > 0 && $this->dbi->isSuperUser()) {
$this->dbi->selectDb('mysql');
Expand Down
5 changes: 2 additions & 3 deletions src/Controllers/Preferences/ExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct(
public function __invoke(ServerRequest $request): Response
{
$GLOBALS['error'] ??= null;
$GLOBALS['hash'] ??= null;

$configFile = new ConfigFile($this->config->baseSettings);
$this->userPreferences->pageInit($configFile);
Expand All @@ -62,8 +61,8 @@ public function __invoke(ServerRequest $request): Response
if ($result === true) {
// reload config
$this->config->loadUserPreferences($this->themeManager);
$GLOBALS['hash'] = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/export', null, $GLOBALS['hash']);
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/export', null, $hash);

return $this->response->response();
}
Expand Down
5 changes: 2 additions & 3 deletions src/Controllers/Preferences/FeaturesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct(
public function __invoke(ServerRequest $request): Response
{
$GLOBALS['error'] ??= null;
$GLOBALS['hash'] ??= null;

$configFile = new ConfigFile($this->config->baseSettings);
$this->userPreferences->pageInit($configFile);
Expand All @@ -62,8 +61,8 @@ public function __invoke(ServerRequest $request): Response
if ($result === true) {
// reload config
$this->config->loadUserPreferences($this->themeManager);
$GLOBALS['hash'] = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/features', null, $GLOBALS['hash']);
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/features', null, $hash);

return $this->response->response();
}
Expand Down
5 changes: 2 additions & 3 deletions src/Controllers/Preferences/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct(
public function __invoke(ServerRequest $request): Response
{
$GLOBALS['error'] ??= null;
$GLOBALS['hash'] ??= null;

$configFile = new ConfigFile($this->config->baseSettings);
$this->userPreferences->pageInit($configFile);
Expand All @@ -62,8 +61,8 @@ public function __invoke(ServerRequest $request): Response
if ($result === true) {
// reload config
$this->config->loadUserPreferences($this->themeManager);
$GLOBALS['hash'] = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/import', null, $GLOBALS['hash']);
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/import', null, $hash);

return $this->response->response();
}
Expand Down
5 changes: 2 additions & 3 deletions src/Controllers/Preferences/MainPanelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct(
public function __invoke(ServerRequest $request): Response
{
$GLOBALS['error'] ??= null;
$GLOBALS['hash'] ??= null;

$configFile = new ConfigFile($this->config->baseSettings);
$this->userPreferences->pageInit($configFile);
Expand All @@ -62,8 +61,8 @@ public function __invoke(ServerRequest $request): Response
if ($result === true) {
// reload config
$this->config->loadUserPreferences($this->themeManager);
$GLOBALS['hash'] = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/main-panel', null, $GLOBALS['hash']);
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/main-panel', null, $hash);

return $this->response->response();
}
Expand Down
5 changes: 2 additions & 3 deletions src/Controllers/Preferences/NavigationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct(
public function __invoke(ServerRequest $request): Response
{
$GLOBALS['error'] ??= null;
$GLOBALS['hash'] ??= null;

$configFile = new ConfigFile($this->config->baseSettings);
$this->userPreferences->pageInit($configFile);
Expand All @@ -62,8 +61,8 @@ public function __invoke(ServerRequest $request): Response
if ($result === true) {
// reload config
$this->config->loadUserPreferences($this->themeManager);
$GLOBALS['hash'] = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/navigation', null, $GLOBALS['hash']);
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/navigation', null, $hash);

return $this->response->response();
}
Expand Down
5 changes: 2 additions & 3 deletions src/Controllers/Preferences/SqlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct(
public function __invoke(ServerRequest $request): Response
{
$GLOBALS['error'] ??= null;
$GLOBALS['hash'] ??= null;

$configFile = new ConfigFile($this->config->baseSettings);
$this->userPreferences->pageInit($configFile);
Expand All @@ -62,8 +61,8 @@ public function __invoke(ServerRequest $request): Response
if ($result === true) {
// reload config
$this->config->loadUserPreferences($this->themeManager);
$GLOBALS['hash'] = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/sql', null, $GLOBALS['hash']);
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
$this->userPreferences->redirect('index.php?route=/preferences/sql', null, $hash);

return $this->response->response();
}
Expand Down
Loading

0 comments on commit ddc64a4

Please sign in to comment.