Remove $route global
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
ef6dbe05ec
commit
47e81a5161
@ -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);
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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 = [];
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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'];
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
@ -2,11 +2,8 @@
|
||||
<files psalm-version="4.18.1@dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb">
|
||||
<file src="index.php">
|
||||
<InvalidGlobal occurrences="1">
|
||||
<code>global $route, $containerBuilder;</code>
|
||||
<code>global $containerBuilder;</code>
|
||||
</InvalidGlobal>
|
||||
<MixedArgument occurrences="1">
|
||||
<code>$route</code>
|
||||
</MixedArgument>
|
||||
</file>
|
||||
<file src="js/messages.php">
|
||||
<UnusedVariable occurrences="1">
|
||||
@ -6444,11 +6441,10 @@
|
||||
<MixedArgumentTypeCoercion occurrences="1">
|
||||
<code>$params</code>
|
||||
</MixedArgumentTypeCoercion>
|
||||
<MixedAssignment occurrences="8">
|
||||
<MixedAssignment occurrences="7">
|
||||
<code>$info</code>
|
||||
<code>$params['checkprivsdb']</code>
|
||||
<code>$params['checkprivstable']</code>
|
||||
<code>$params['route']</code>
|
||||
<code>$params['server']</code>
|
||||
<code>$params['single_table']</code>
|
||||
<code>$params['viewing_mode']</code>
|
||||
@ -9069,18 +9065,14 @@
|
||||
<code>$serverCookie</code>
|
||||
<code>$tmp_host</code>
|
||||
</MixedArgument>
|
||||
<MixedArgumentTypeCoercion occurrences="1">
|
||||
<code>$url_params</code>
|
||||
</MixedArgumentTypeCoercion>
|
||||
<MixedArrayAccess occurrences="1">
|
||||
<code>$_SESSION['browser_access_time'][$key]</code>
|
||||
</MixedArrayAccess>
|
||||
<MixedArrayOffset occurrences="1">
|
||||
<code>$_SESSION['browser_access_time'][$key]</code>
|
||||
</MixedArrayOffset>
|
||||
<MixedAssignment occurrences="14">
|
||||
<MixedAssignment occurrences="12">
|
||||
<code>$GLOBALS['pma_auth_server']</code>
|
||||
<code>$_form_params['route']</code>
|
||||
<code>$captchaSiteVerifyURL</code>
|
||||
<code>$captchaSiteVerifyURL</code>
|
||||
<code>$key</code>
|
||||
@ -9091,7 +9083,6 @@
|
||||
<code>$serverCookie</code>
|
||||
<code>$this->password</code>
|
||||
<code>$tmp_host</code>
|
||||
<code>$url_params['route']</code>
|
||||
<code>$value</code>
|
||||
</MixedAssignment>
|
||||
<MixedMethodCall occurrences="6">
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user