diff --git a/index.php b/index.php index 12b2f095e6..8c5eaf5cf9 100644 --- a/index.php +++ b/index.php @@ -35,9 +35,9 @@ if (! @is_readable(AUTOLOAD_FILE)) { require AUTOLOAD_FILE; -global $route, $containerBuilder; +global $containerBuilder; Common::run(); $dispatcher = Routing::getDispatcher(); -Routing::callControllerForRoute(Common::getRequest(), $route, $dispatcher, $containerBuilder); +Routing::callControllerForRoute(Common::getRequest(), Routing::getCurrentRoute(), $dispatcher, $containerBuilder); diff --git a/libraries/classes/Common.php b/libraries/classes/Common.php index eb537d4b8b..771da448a4 100644 --- a/libraries/classes/Common.php +++ b/libraries/classes/Common.php @@ -81,7 +81,7 @@ final class Common public static function run(): void { global $containerBuilder, $errorHandler, $config, $server, $dbi; - global $lang, $cfg, $isConfigLoading, $auth_plugin, $route, $theme; + global $lang, $cfg, $isConfigLoading, $auth_plugin, $theme; global $urlParams, $isMinimumCommon, $sql_query, $token_mismatch; $request = self::getRequest(); diff --git a/libraries/classes/Controllers/Preferences/ExportController.php b/libraries/classes/Controllers/Preferences/ExportController.php index 3acdf6c372..313f635012 100644 --- a/libraries/classes/Controllers/Preferences/ExportController.php +++ b/libraries/classes/Controllers/Preferences/ExportController.php @@ -10,6 +10,7 @@ use PhpMyAdmin\Config\Forms\User\ExportForm; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Template; use PhpMyAdmin\TwoFactor; use PhpMyAdmin\Url; @@ -44,7 +45,9 @@ class ExportController extends AbstractController public function __invoke(): void { - global $cfg, $cf, $error, $tabHash, $hash, $server, $route; + global $cfg, $cf, $error, $tabHash, $hash, $server; + + $route = Routing::getCurrentRoute(); $cf = new ConfigFile($this->config->baseSettings); $this->userPreferences->pageInit($cf); diff --git a/libraries/classes/Controllers/Preferences/FeaturesController.php b/libraries/classes/Controllers/Preferences/FeaturesController.php index 4fb7f2d3b0..8d8d986a2d 100644 --- a/libraries/classes/Controllers/Preferences/FeaturesController.php +++ b/libraries/classes/Controllers/Preferences/FeaturesController.php @@ -10,6 +10,7 @@ use PhpMyAdmin\Config\Forms\User\FeaturesForm; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Template; use PhpMyAdmin\TwoFactor; use PhpMyAdmin\Url; @@ -44,7 +45,9 @@ class FeaturesController extends AbstractController public function __invoke(): void { - global $cfg, $cf, $error, $tabHash, $hash, $server, $route; + global $cfg, $cf, $error, $tabHash, $hash, $server; + + $route = Routing::getCurrentRoute(); $cf = new ConfigFile($this->config->baseSettings); $this->userPreferences->pageInit($cf); diff --git a/libraries/classes/Controllers/Preferences/ImportController.php b/libraries/classes/Controllers/Preferences/ImportController.php index 2d4e59ebea..48755f5661 100644 --- a/libraries/classes/Controllers/Preferences/ImportController.php +++ b/libraries/classes/Controllers/Preferences/ImportController.php @@ -10,6 +10,7 @@ use PhpMyAdmin\Config\Forms\User\ImportForm; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Template; use PhpMyAdmin\TwoFactor; use PhpMyAdmin\Url; @@ -44,7 +45,9 @@ class ImportController extends AbstractController public function __invoke(): void { - global $cfg, $cf, $error, $tabHash, $hash, $server, $route; + global $cfg, $cf, $error, $tabHash, $hash, $server; + + $route = Routing::getCurrentRoute(); $cf = new ConfigFile($this->config->baseSettings); $this->userPreferences->pageInit($cf); diff --git a/libraries/classes/Controllers/Preferences/MainPanelController.php b/libraries/classes/Controllers/Preferences/MainPanelController.php index 95042886a4..afdfd4d3ce 100644 --- a/libraries/classes/Controllers/Preferences/MainPanelController.php +++ b/libraries/classes/Controllers/Preferences/MainPanelController.php @@ -10,6 +10,7 @@ use PhpMyAdmin\Config\Forms\User\MainForm; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Template; use PhpMyAdmin\TwoFactor; use PhpMyAdmin\Url; @@ -44,7 +45,9 @@ class MainPanelController extends AbstractController public function __invoke(): void { - global $cfg, $cf, $error, $tabHash, $hash, $server, $route; + global $cfg, $cf, $error, $tabHash, $hash, $server; + + $route = Routing::getCurrentRoute(); $cf = new ConfigFile($this->config->baseSettings); $this->userPreferences->pageInit($cf); diff --git a/libraries/classes/Controllers/Preferences/ManageController.php b/libraries/classes/Controllers/Preferences/ManageController.php index 6452e4746f..e693397a69 100644 --- a/libraries/classes/Controllers/Preferences/ManageController.php +++ b/libraries/classes/Controllers/Preferences/ManageController.php @@ -13,6 +13,7 @@ use PhpMyAdmin\Core; use PhpMyAdmin\File; use PhpMyAdmin\Message; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Template; use PhpMyAdmin\ThemeManager; use PhpMyAdmin\UserPreferences; @@ -67,7 +68,9 @@ class ManageController extends AbstractController public function __invoke(): void { global $cf, $error, $filename, $json, $lang; - global $new_config, $return_url, $form_display, $all_ok, $params, $query, $route; + global $new_config, $return_url, $form_display, $all_ok, $params, $query; + + $route = Routing::getCurrentRoute(); $cf = new ConfigFile($this->config->baseSettings); $this->userPreferences->pageInit($cf); diff --git a/libraries/classes/Controllers/Preferences/NavigationController.php b/libraries/classes/Controllers/Preferences/NavigationController.php index 64b9cc7b16..fdce42afb2 100644 --- a/libraries/classes/Controllers/Preferences/NavigationController.php +++ b/libraries/classes/Controllers/Preferences/NavigationController.php @@ -10,6 +10,7 @@ use PhpMyAdmin\Config\Forms\User\NaviForm; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Template; use PhpMyAdmin\TwoFactor; use PhpMyAdmin\Url; @@ -44,7 +45,9 @@ class NavigationController extends AbstractController public function __invoke(): void { - global $cfg, $cf, $error, $tabHash, $hash, $server, $route; + global $cfg, $cf, $error, $tabHash, $hash, $server; + + $route = Routing::getCurrentRoute(); $cf = new ConfigFile($this->config->baseSettings); $this->userPreferences->pageInit($cf); diff --git a/libraries/classes/Controllers/Preferences/SqlController.php b/libraries/classes/Controllers/Preferences/SqlController.php index 78253e518f..29de30c7db 100644 --- a/libraries/classes/Controllers/Preferences/SqlController.php +++ b/libraries/classes/Controllers/Preferences/SqlController.php @@ -10,6 +10,7 @@ use PhpMyAdmin\Config\Forms\User\SqlForm; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Template; use PhpMyAdmin\TwoFactor; use PhpMyAdmin\Url; @@ -44,7 +45,9 @@ class SqlController extends AbstractController public function __invoke(): void { - global $cfg, $cf, $error, $tabHash, $hash, $server, $route; + global $cfg, $cf, $error, $tabHash, $hash, $server; + + $route = Routing::getCurrentRoute(); $cf = new ConfigFile($this->config->baseSettings); $this->userPreferences->pageInit($cf); diff --git a/libraries/classes/Controllers/Preferences/TwoFactorController.php b/libraries/classes/Controllers/Preferences/TwoFactorController.php index ccd7ea6638..47d888bc8e 100644 --- a/libraries/classes/Controllers/Preferences/TwoFactorController.php +++ b/libraries/classes/Controllers/Preferences/TwoFactorController.php @@ -8,6 +8,7 @@ use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\Message; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Template; use PhpMyAdmin\TwoFactor; @@ -27,7 +28,9 @@ class TwoFactorController extends AbstractController public function __invoke(): void { - global $cfg, $route; + global $cfg; + + $route = Routing::getCurrentRoute(); $relationParameters = $this->relation->getRelationParameters(); diff --git a/libraries/classes/Controllers/Table/RelationController.php b/libraries/classes/Controllers/Table/RelationController.php index dca69b8a22..040eb941b8 100644 --- a/libraries/classes/Controllers/Table/RelationController.php +++ b/libraries/classes/Controllers/Table/RelationController.php @@ -12,6 +12,7 @@ use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\Html\Generator; use PhpMyAdmin\Index; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Table; use PhpMyAdmin\Template; use PhpMyAdmin\Util; @@ -58,7 +59,7 @@ final class RelationController extends AbstractController */ public function __invoke(): void { - global $route; + $route = Routing::getCurrentRoute(); $options = [ 'CASCADE' => 'CASCADE', diff --git a/libraries/classes/Controllers/Table/StructureController.php b/libraries/classes/Controllers/Table/StructureController.php index 1c7507aa38..114fc6e714 100644 --- a/libraries/classes/Controllers/Table/StructureController.php +++ b/libraries/classes/Controllers/Table/StructureController.php @@ -21,6 +21,7 @@ use PhpMyAdmin\Index; use PhpMyAdmin\Partitioning\Partition; use PhpMyAdmin\Query\Utilities; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\StorageEngine; use PhpMyAdmin\Table; use PhpMyAdmin\Template; @@ -164,7 +165,9 @@ class StructureController extends AbstractController array $columns_with_index, bool $isSystemSchema ) { - global $route, $tbl_is_view, $tbl_storage_engine; + global $tbl_is_view, $tbl_storage_engine; + + $route = Routing::getCurrentRoute(); // prepare comments $comments_map = []; diff --git a/libraries/classes/Footer.php b/libraries/classes/Footer.php index 29c5d981f4..05d259fce9 100644 --- a/libraries/classes/Footer.php +++ b/libraries/classes/Footer.php @@ -140,12 +140,10 @@ class Footer */ public function getSelfUrl(): string { - global $route, $db, $table, $server; + global $db, $table, $server; $params = []; - if (isset($route)) { - $params['route'] = $route; - } + $params['route'] = Routing::getCurrentRoute(); if (isset($db) && strlen($db) > 0) { $params['db'] = $db; diff --git a/libraries/classes/Menu.php b/libraries/classes/Menu.php index 17d89b05ce..20cb496654 100644 --- a/libraries/classes/Menu.php +++ b/libraries/classes/Menu.php @@ -220,7 +220,7 @@ class Menu */ private function getTableTabs(): array { - global $route; + $route = Routing::getCurrentRoute(); $isSystemSchema = Utilities::isSystemSchema($this->db); $tableIsView = $this->dbi->getTable($this->db, $this->table) @@ -342,7 +342,7 @@ class Menu */ private function getDbTabs(): array { - global $route; + $route = Routing::getCurrentRoute(); $isSystemSchema = Utilities::isSystemSchema($this->db); $numTables = count($this->dbi->getTables($this->db)); @@ -459,7 +459,7 @@ class Menu */ private function getServerTabs(): array { - global $route; + $route = Routing::getCurrentRoute(); $isSuperUser = $this->dbi->isSuperUser(); $isCreateOrGrantUser = $this->dbi->isGrantUser() || $this->dbi->isCreateUser(); diff --git a/libraries/classes/Plugins/Auth/AuthenticationCookie.php b/libraries/classes/Plugins/Auth/AuthenticationCookie.php index 33faf56b34..28b5fd99fb 100644 --- a/libraries/classes/Plugins/Auth/AuthenticationCookie.php +++ b/libraries/classes/Plugins/Auth/AuthenticationCookie.php @@ -13,6 +13,7 @@ use PhpMyAdmin\LanguageManager; use PhpMyAdmin\Message; use PhpMyAdmin\Plugins\AuthenticationPlugin; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Server\Select; use PhpMyAdmin\Session; use PhpMyAdmin\Url; @@ -63,7 +64,7 @@ class AuthenticationCookie extends AuthenticationPlugin */ public function showLoginForm(): bool { - global $conn_error, $route; + global $conn_error; $response = ResponseRenderer::getInstance(); @@ -147,9 +148,7 @@ class AuthenticationCookie extends AuthenticationPlugin } $_form_params = []; - if (isset($route)) { - $_form_params['route'] = $route; - } + $_form_params['route'] = Routing::getCurrentRoute(); if (strlen($GLOBALS['db'])) { $_form_params['db'] = $GLOBALS['db']; @@ -455,8 +454,6 @@ class AuthenticationCookie extends AuthenticationPlugin */ public function rememberCredentials(): void { - global $route; - // Name and password cookies need to be refreshed each time // Duration = one month for username $this->storeUsernameCookie($this->user); @@ -470,9 +467,7 @@ class AuthenticationCookie extends AuthenticationPlugin // any parameters to pass? $url_params = []; - if (isset($route)) { - $url_params['route'] = $route; - } + $url_params['route'] = Routing::getCurrentRoute(); if (strlen($GLOBALS['db']) > 0) { $url_params['db'] = $GLOBALS['db']; diff --git a/libraries/classes/Server/Privileges.php b/libraries/classes/Server/Privileges.php index d91d882afc..1d1a315a53 100644 --- a/libraries/classes/Server/Privileges.php +++ b/libraries/classes/Server/Privileges.php @@ -19,6 +19,7 @@ use PhpMyAdmin\Html\MySQLDocumentation; use PhpMyAdmin\Message; use PhpMyAdmin\Query\Compatibility; use PhpMyAdmin\ResponseRenderer; +use PhpMyAdmin\Routing; use PhpMyAdmin\Template; use PhpMyAdmin\Url; use PhpMyAdmin\Util; @@ -3710,7 +3711,7 @@ class Privileges public function getFormForChangePassword(string $username, string $hostname, bool $editOthers): string { - global $route; + $route = Routing::getCurrentRoute(); $isPrivileges = $route === '/server/privileges'; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4db101aced..d527d2ae2c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2,11 +2,8 @@ - global $route, $containerBuilder; + global $containerBuilder; - - $route - @@ -6444,11 +6441,10 @@ $params - + $info $params['checkprivsdb'] $params['checkprivstable'] - $params['route'] $params['server'] $params['single_table'] $params['viewing_mode'] @@ -9069,18 +9065,14 @@ $serverCookie $tmp_host - - $url_params - $_SESSION['browser_access_time'][$key] $_SESSION['browser_access_time'][$key] - + $GLOBALS['pma_auth_server'] - $_form_params['route'] $captchaSiteVerifyURL $captchaSiteVerifyURL $key @@ -9091,7 +9083,6 @@ $serverCookie $this->password $tmp_host - $url_params['route'] $value diff --git a/test/classes/Server/PrivilegesTest.php b/test/classes/Server/PrivilegesTest.php index cee9e1e941..d0910334ff 100644 --- a/test/classes/Server/PrivilegesTest.php +++ b/test/classes/Server/PrivilegesTest.php @@ -1817,11 +1817,9 @@ class PrivilegesTest extends AbstractTestCase public function testGetFormForChangePassword(): void { - global $route; - $username = 'pma_username'; $hostname = 'pma_hostname'; - $route = '/server/privileges'; + $_GET['route'] = '/server/privileges'; $html = $this->serverPrivileges->getFormForChangePassword($username, $hostname, false);