Extract privileges globals to static props of UserPrivileges class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
a5850a03ee
commit
4fefea40c7
@ -185,11 +185,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Charsets.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access an offset on mixed\\.$#"
|
||||
count: 1
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Only booleans are allowed in a negated boolean, PhpMyAdmin\\\\Dbal\\\\ResultInterface\\|false given\\.$#"
|
||||
count: 1
|
||||
@ -215,6 +210,51 @@ parameters:
|
||||
count: 1
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$column \\(bool\\) does not accept mixed\\.$#"
|
||||
count: 1
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$database \\(bool\\) does not accept mixed\\.$#"
|
||||
count: 1
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$databaseToCreate \\(string\\) does not accept mixed\\.$#"
|
||||
count: 1
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$databaseToCreate \\(string\\) does not accept string\\|null\\.$#"
|
||||
count: 2
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$databasesToTest \\(array\\<string\\>\\|false\\) does not accept mixed\\.$#"
|
||||
count: 2
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$isCreateDatabase \\(bool\\) does not accept mixed\\.$#"
|
||||
count: 1
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$isReload \\(bool\\) does not accept mixed\\.$#"
|
||||
count: 1
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$routines \\(bool\\) does not accept mixed\\.$#"
|
||||
count: 1
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$table \\(bool\\) does not accept mixed\\.$#"
|
||||
count: 1
|
||||
path: src/CheckUserPrivileges.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$source of method PhpMyAdmin\\\\Config\\:\\:loadAndCheck\\(\\) expects string\\|null, mixed given\\.$#"
|
||||
count: 1
|
||||
@ -9845,11 +9885,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Linter.php
|
||||
|
||||
-
|
||||
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
|
||||
count: 1
|
||||
path: src/ListDatabase.php
|
||||
|
||||
-
|
||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||
count: 1
|
||||
@ -9865,11 +9900,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/ListDatabase.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$likeDbName of method PhpMyAdmin\\\\ListDatabase\\:\\:retrieve\\(\\) expects string\\|null, mixed given\\.$#"
|
||||
count: 1
|
||||
path: src/ListDatabase.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$str of function strtr expects string, array\\<string\\>\\|bool\\|int\\<0, max\\>\\|string given\\.$#"
|
||||
count: 1
|
||||
@ -9982,7 +10012,7 @@ parameters:
|
||||
|
||||
-
|
||||
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
|
||||
count: 2
|
||||
count: 1
|
||||
path: src/Navigation/NavigationTree.php
|
||||
|
||||
-
|
||||
@ -10157,11 +10187,11 @@ parameters:
|
||||
|
||||
-
|
||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||
count: 5
|
||||
count: 4
|
||||
path: src/Navigation/Nodes/Node.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\:\\:getDatabasesToSearch\\(\\) should return array but returns mixed\\.$#"
|
||||
message: "#^Method PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\:\\:getDatabasesToSearch\\(\\) should return array but returns array\\<string\\>\\|string\\.$#"
|
||||
count: 1
|
||||
path: src/Navigation/Nodes/Node.php
|
||||
|
||||
@ -10171,7 +10201,7 @@ parameters:
|
||||
path: src/Navigation/Nodes/Node.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$array of function sort expects TArray of array\\<T\\>, mixed given\\.$#"
|
||||
message: "#^Parameter \\#1 \\$array of function sort expects TArray of array\\<string\\>, array\\<string\\>\\|string given\\.$#"
|
||||
count: 1
|
||||
path: src/Navigation/Nodes/Node.php
|
||||
|
||||
|
||||
@ -132,14 +132,14 @@
|
||||
</file>
|
||||
<file src="src/CheckUserPrivileges.php">
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['col_priv']]]></code>
|
||||
<code><![CDATA[$GLOBALS['db_priv']]]></code>
|
||||
<code><![CDATA[$GLOBALS['db_to_create']]]></code>
|
||||
<code><![CDATA[$GLOBALS['dbs_to_test']]]></code>
|
||||
<code><![CDATA[$GLOBALS['is_create_db_priv']]]></code>
|
||||
<code><![CDATA[$GLOBALS['is_reload_priv']]]></code>
|
||||
<code><![CDATA[$GLOBALS['proc_priv']]]></code>
|
||||
<code><![CDATA[$GLOBALS['table_priv']]]></code>
|
||||
<code>UserPrivileges::$column</code>
|
||||
<code>UserPrivileges::$database</code>
|
||||
<code>UserPrivileges::$databaseToCreate</code>
|
||||
<code>UserPrivileges::$databasesToTest</code>
|
||||
<code>UserPrivileges::$isCreateDatabase</code>
|
||||
<code>UserPrivileges::$isReload</code>
|
||||
<code>UserPrivileges::$routines</code>
|
||||
<code>UserPrivileges::$table</code>
|
||||
</MixedAssignment>
|
||||
</file>
|
||||
<file src="src/Command/CacheWarmupCommand.php">
|
||||
@ -2674,7 +2674,6 @@
|
||||
<code>Config::getInstance()</code>
|
||||
</DeprecatedMethod>
|
||||
<InvalidArrayOffset>
|
||||
<code><![CDATA[$GLOBALS['db_to_create']]]></code>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
</InvalidArrayOffset>
|
||||
<MixedArgument>
|
||||
@ -2716,7 +2715,6 @@
|
||||
<code><![CDATA[$databases[$database['SCHEMA_NAME']]]]></code>
|
||||
</MixedArrayOffset>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['db_to_create']]]></code>
|
||||
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
|
||||
<code>$database</code>
|
||||
<code>$key</code>
|
||||
@ -7246,6 +7244,7 @@
|
||||
<code>DatabaseInterface::getInstance()</code>
|
||||
</DeprecatedMethod>
|
||||
<MixedArgument>
|
||||
<code>$databases</code>
|
||||
<code>$db</code>
|
||||
<code>$db</code>
|
||||
<code>$db</code>
|
||||
@ -7253,15 +7252,13 @@
|
||||
<code>$db</code>
|
||||
</MixedArgument>
|
||||
<MixedAssignment>
|
||||
<code>$databases</code>
|
||||
<code>$db</code>
|
||||
<code>$db</code>
|
||||
<code>$db</code>
|
||||
<code>$db</code>
|
||||
<code>$db</code>
|
||||
</MixedAssignment>
|
||||
<PossiblyInvalidArgument>
|
||||
<code>$databases</code>
|
||||
</PossiblyInvalidArgument>
|
||||
<PossiblyNullArgument>
|
||||
<code>$arr[0]</code>
|
||||
<code>$arr[0]</code>
|
||||
|
||||
@ -45,7 +45,6 @@
|
||||
charset: string,
|
||||
charset_connection: string,
|
||||
codegen_format: 0|1,
|
||||
col_priv: bool,
|
||||
collation_connection: string,
|
||||
complete_query: string,
|
||||
compression: 'none'|'zip'|'gzip',
|
||||
@ -56,8 +55,6 @@
|
||||
csv_escaped: string,
|
||||
csv_separator: string,
|
||||
csv_terminated: string,
|
||||
db_priv: bool,
|
||||
dbs_to_test: string[]|false,
|
||||
display_query: string,
|
||||
errno: int,
|
||||
error: bool,
|
||||
@ -71,8 +68,6 @@
|
||||
import_file: string,
|
||||
import_file_name: string,
|
||||
import_text: string,
|
||||
is_create_db_priv: bool,
|
||||
is_reload_priv: bool,
|
||||
knjenc: string,
|
||||
lang: string,
|
||||
latex_data_caption: string,
|
||||
@ -97,7 +92,6 @@
|
||||
plugin_scripts: string[],
|
||||
pma_auth_server: string,
|
||||
PMA_PHP_SELF: string,
|
||||
proc_priv: bool,
|
||||
querytime: float|int,
|
||||
read_limit: int,
|
||||
save_on_server: bool,
|
||||
@ -114,7 +108,6 @@
|
||||
sql_query: string,
|
||||
sql_structure_or_data: 'structure'|'data'|'structure_and_data',
|
||||
sql_type: 'INSERT'|'UPDATE'|'REPLACE',
|
||||
table_priv: bool,
|
||||
tbl_storage_engine: string,
|
||||
token_mismatch: bool,
|
||||
token_provided: bool,
|
||||
|
||||
@ -44,13 +44,13 @@ class CheckUserPrivileges
|
||||
}
|
||||
|
||||
if ($showGrants->dbName === '*' && $showGrants->tableName === '*') {
|
||||
$GLOBALS['col_priv'] = true;
|
||||
$GLOBALS['db_priv'] = true;
|
||||
$GLOBALS['proc_priv'] = true;
|
||||
$GLOBALS['table_priv'] = true;
|
||||
UserPrivileges::$column = true;
|
||||
UserPrivileges::$database = true;
|
||||
UserPrivileges::$routines = true;
|
||||
UserPrivileges::$table = true;
|
||||
|
||||
if ($showGrants->grants === 'ALL PRIVILEGES' || $showGrants->grants === 'ALL') {
|
||||
$GLOBALS['is_reload_priv'] = true;
|
||||
UserPrivileges::$isReload = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,22 +62,22 @@ class CheckUserPrivileges
|
||||
|
||||
switch ($showGrants->tableName) {
|
||||
case 'columns_priv':
|
||||
$GLOBALS['col_priv'] = true;
|
||||
UserPrivileges::$column = true;
|
||||
break;
|
||||
case 'db':
|
||||
$GLOBALS['db_priv'] = true;
|
||||
UserPrivileges::$database = true;
|
||||
break;
|
||||
case 'procs_priv':
|
||||
$GLOBALS['proc_priv'] = true;
|
||||
UserPrivileges::$routines = true;
|
||||
break;
|
||||
case 'tables_priv':
|
||||
$GLOBALS['table_priv'] = true;
|
||||
UserPrivileges::$table = true;
|
||||
break;
|
||||
case '*':
|
||||
$GLOBALS['col_priv'] = true;
|
||||
$GLOBALS['db_priv'] = true;
|
||||
$GLOBALS['proc_priv'] = true;
|
||||
$GLOBALS['table_priv'] = true;
|
||||
UserPrivileges::$column = true;
|
||||
UserPrivileges::$database = true;
|
||||
UserPrivileges::$routines = true;
|
||||
UserPrivileges::$table = true;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
@ -102,28 +102,28 @@ class CheckUserPrivileges
|
||||
private function analyseShowGrant(): void
|
||||
{
|
||||
if (SessionCache::has('is_create_db_priv')) {
|
||||
$GLOBALS['is_create_db_priv'] = SessionCache::get('is_create_db_priv');
|
||||
$GLOBALS['is_reload_priv'] = SessionCache::get('is_reload_priv');
|
||||
$GLOBALS['db_to_create'] = SessionCache::get('db_to_create');
|
||||
$GLOBALS['dbs_to_test'] = SessionCache::get('dbs_to_test');
|
||||
UserPrivileges::$isCreateDatabase = SessionCache::get('is_create_db_priv');
|
||||
UserPrivileges::$isReload = SessionCache::get('is_reload_priv');
|
||||
UserPrivileges::$databaseToCreate = SessionCache::get('db_to_create');
|
||||
UserPrivileges::$databasesToTest = SessionCache::get('dbs_to_test');
|
||||
|
||||
$GLOBALS['db_priv'] = SessionCache::get('db_priv');
|
||||
$GLOBALS['col_priv'] = SessionCache::get('col_priv');
|
||||
$GLOBALS['table_priv'] = SessionCache::get('table_priv');
|
||||
$GLOBALS['proc_priv'] = SessionCache::get('proc_priv');
|
||||
UserPrivileges::$database = SessionCache::get('db_priv');
|
||||
UserPrivileges::$column = SessionCache::get('col_priv');
|
||||
UserPrivileges::$table = SessionCache::get('table_priv');
|
||||
UserPrivileges::$routines = SessionCache::get('proc_priv');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// defaults
|
||||
$GLOBALS['is_create_db_priv'] = false;
|
||||
$GLOBALS['is_reload_priv'] = false;
|
||||
$GLOBALS['db_to_create'] = '';
|
||||
$GLOBALS['dbs_to_test'] = Utilities::getSystemSchemas();
|
||||
$GLOBALS['proc_priv'] = false;
|
||||
$GLOBALS['db_priv'] = false;
|
||||
$GLOBALS['col_priv'] = false;
|
||||
$GLOBALS['table_priv'] = false;
|
||||
UserPrivileges::$isCreateDatabase = false;
|
||||
UserPrivileges::$isReload = false;
|
||||
UserPrivileges::$databaseToCreate = '';
|
||||
UserPrivileges::$databasesToTest = Utilities::getSystemSchemas();
|
||||
UserPrivileges::$routines = false;
|
||||
UserPrivileges::$database = false;
|
||||
UserPrivileges::$column = false;
|
||||
UserPrivileges::$table = false;
|
||||
|
||||
$showGrantsResult = $this->dbi->tryQuery('SHOW GRANTS');
|
||||
|
||||
@ -139,14 +139,14 @@ class CheckUserPrivileges
|
||||
|
||||
if ($showGrants->dbName === '*') {
|
||||
if ($showGrants->grants !== 'USAGE') {
|
||||
$GLOBALS['dbs_to_test'] = false;
|
||||
UserPrivileges::$databasesToTest = false;
|
||||
}
|
||||
} elseif ($GLOBALS['dbs_to_test'] !== false) {
|
||||
$GLOBALS['dbs_to_test'][] = $showGrants->dbName;
|
||||
} elseif (UserPrivileges::$databasesToTest !== false) {
|
||||
UserPrivileges::$databasesToTest[] = $showGrants->dbName;
|
||||
}
|
||||
|
||||
if (str_contains($showGrants->grants, 'RELOAD')) {
|
||||
$GLOBALS['is_reload_priv'] = true;
|
||||
UserPrivileges::$isReload = true;
|
||||
}
|
||||
|
||||
// check for the required privileges for adjust
|
||||
@ -167,9 +167,9 @@ class CheckUserPrivileges
|
||||
|
||||
if ($showGrants->dbName === '*') {
|
||||
// a global CREATE privilege
|
||||
$GLOBALS['is_create_db_priv'] = true;
|
||||
$GLOBALS['is_reload_priv'] = true;
|
||||
$GLOBALS['db_to_create'] = '';
|
||||
UserPrivileges::$isCreateDatabase = true;
|
||||
UserPrivileges::$isReload = true;
|
||||
UserPrivileges::$databaseToCreate = '';
|
||||
// @todo we should not break here, cause GRANT ALL *.*
|
||||
// could be revoked by a later rule like GRANT SELECT ON db.*
|
||||
break;
|
||||
@ -177,7 +177,7 @@ class CheckUserPrivileges
|
||||
|
||||
$dbNameToTest = Util::backquote($showGrants->dbName);
|
||||
|
||||
if ($GLOBALS['is_create_db_priv']) {
|
||||
if (UserPrivileges::$isCreateDatabase) {
|
||||
// no need for any more tests if we already know this
|
||||
continue;
|
||||
}
|
||||
@ -202,12 +202,16 @@ class CheckUserPrivileges
|
||||
* Do not handle the underscore wildcard
|
||||
* (this case must be rare anyway)
|
||||
*/
|
||||
$GLOBALS['db_to_create'] = preg_replace('/' . $re0 . '%/', '\\1', $showGrants->dbName);
|
||||
$GLOBALS['db_to_create'] = preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $GLOBALS['db_to_create']);
|
||||
$GLOBALS['is_create_db_priv'] = true;
|
||||
UserPrivileges::$databaseToCreate = preg_replace('/' . $re0 . '%/', '\\1', $showGrants->dbName);
|
||||
UserPrivileges::$databaseToCreate = preg_replace(
|
||||
'/' . $re1 . '(%|_)/',
|
||||
'\\1\\3',
|
||||
UserPrivileges::$databaseToCreate,
|
||||
);
|
||||
UserPrivileges::$isCreateDatabase = true;
|
||||
|
||||
/**
|
||||
* @todo collect $GLOBALS['db_to_create'] into an array,
|
||||
* @todo collect \PhpMyAdmin\UserPrivileges::$dbToCreate into an array,
|
||||
* to display a drop-down in the "Create database" dialog
|
||||
*/
|
||||
// we don't break, we want all possible databases
|
||||
@ -216,15 +220,15 @@ class CheckUserPrivileges
|
||||
|
||||
// must also cacheUnset() them in
|
||||
// PhpMyAdmin\Plugins\Auth\AuthenticationCookie
|
||||
SessionCache::set('is_create_db_priv', $GLOBALS['is_create_db_priv']);
|
||||
SessionCache::set('is_reload_priv', $GLOBALS['is_reload_priv']);
|
||||
SessionCache::set('db_to_create', $GLOBALS['db_to_create']);
|
||||
SessionCache::set('dbs_to_test', $GLOBALS['dbs_to_test']);
|
||||
SessionCache::set('is_create_db_priv', UserPrivileges::$isCreateDatabase);
|
||||
SessionCache::set('is_reload_priv', UserPrivileges::$isReload);
|
||||
SessionCache::set('db_to_create', UserPrivileges::$databaseToCreate);
|
||||
SessionCache::set('dbs_to_test', UserPrivileges::$databasesToTest);
|
||||
|
||||
SessionCache::set('proc_priv', $GLOBALS['proc_priv']);
|
||||
SessionCache::set('table_priv', $GLOBALS['table_priv']);
|
||||
SessionCache::set('col_priv', $GLOBALS['col_priv']);
|
||||
SessionCache::set('db_priv', $GLOBALS['db_priv']);
|
||||
SessionCache::set('proc_priv', UserPrivileges::$routines);
|
||||
SessionCache::set('table_priv', UserPrivileges::$table);
|
||||
SessionCache::set('col_priv', UserPrivileges::$column);
|
||||
SessionCache::set('db_priv', UserPrivileges::$database);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,14 +245,14 @@ class CheckUserPrivileges
|
||||
|
||||
// If MySQL is started with --skip-grant-tables
|
||||
if ($username === '') {
|
||||
$GLOBALS['is_create_db_priv'] = true;
|
||||
$GLOBALS['is_reload_priv'] = true;
|
||||
$GLOBALS['db_to_create'] = '';
|
||||
$GLOBALS['dbs_to_test'] = false;
|
||||
$GLOBALS['db_priv'] = true;
|
||||
$GLOBALS['col_priv'] = true;
|
||||
$GLOBALS['table_priv'] = true;
|
||||
$GLOBALS['proc_priv'] = true;
|
||||
UserPrivileges::$isCreateDatabase = true;
|
||||
UserPrivileges::$isReload = true;
|
||||
UserPrivileges::$databaseToCreate = '';
|
||||
UserPrivileges::$databasesToTest = false;
|
||||
UserPrivileges::$database = true;
|
||||
UserPrivileges::$column = true;
|
||||
UserPrivileges::$table = true;
|
||||
UserPrivileges::$routines = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
@ -263,7 +264,7 @@ class RoutinesController extends AbstractController
|
||||
'parameter_rows' => $parameterRows,
|
||||
'charsets' => $charsets,
|
||||
'numeric_options' => $this->routines->numericOptions,
|
||||
'has_privileges' => $GLOBALS['proc_priv'] && $GLOBALS['is_reload_priv'],
|
||||
'has_privileges' => UserPrivileges::$routines && UserPrivileges::$isReload,
|
||||
'sql_data_access' => $this->routines->sqlDataAccess,
|
||||
]);
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ use PhpMyAdmin\Query\Utilities;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
@ -259,8 +260,8 @@ class DatabaseController extends AbstractController
|
||||
$databaseComment = $this->relation->getDbComment(Current::$database);
|
||||
}
|
||||
|
||||
$hasAdjustPrivileges = $GLOBALS['db_priv'] && $GLOBALS['table_priv']
|
||||
&& $GLOBALS['col_priv'] && $GLOBALS['proc_priv'] && $GLOBALS['is_reload_priv'];
|
||||
$hasAdjustPrivileges = UserPrivileges::$database && UserPrivileges::$table
|
||||
&& UserPrivileges::$column && UserPrivileges::$routines && UserPrivileges::$isReload;
|
||||
|
||||
$isDropDatabaseAllowed = ($this->dbi->isSuperUser() || $config->settings['AllowUserDropDatabase'])
|
||||
&& Current::$database !== 'mysql';
|
||||
|
||||
@ -26,6 +26,7 @@ use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\StorageEngine;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
@ -469,7 +470,7 @@ class TableController extends AbstractController
|
||||
}
|
||||
|
||||
$hasForeignKeys = $this->relation->getForeigners(Current::$database, Current::$table, '', 'foreign') !== [];
|
||||
$hasPrivileges = $GLOBALS['table_priv'] && $GLOBALS['col_priv'] && $GLOBALS['is_reload_priv'];
|
||||
$hasPrivileges = UserPrivileges::$table && UserPrivileges::$column && UserPrivileges::$isReload;
|
||||
$switchToNew = isset($_SESSION['pma_switch_to_new']) && $_SESSION['pma_switch_to_new'];
|
||||
|
||||
$partitions = [];
|
||||
|
||||
@ -18,6 +18,7 @@ use PhpMyAdmin\Replication\ReplicationInfo;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
@ -61,8 +62,6 @@ class DatabasesController extends AbstractController
|
||||
|
||||
public function __invoke(ServerRequest $request): void
|
||||
{
|
||||
$GLOBALS['is_create_db_priv'] ??= null;
|
||||
$GLOBALS['db_to_create'] ??= null;
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
|
||||
$params = [
|
||||
@ -116,7 +115,7 @@ class DatabasesController extends AbstractController
|
||||
|
||||
$charsetsList = [];
|
||||
$config = Config::getInstance();
|
||||
if ($config->settings['ShowCreateDb'] && $GLOBALS['is_create_db_priv']) {
|
||||
if ($config->settings['ShowCreateDb'] && UserPrivileges::$isCreateDatabase) {
|
||||
$charsets = Charsets::getCharsets($this->dbi, $config->selectedServer['DisableIS']);
|
||||
$collations = Charsets::getCollations($this->dbi, $config->selectedServer['DisableIS']);
|
||||
$serverCollation = $this->dbi->getServerCollation();
|
||||
@ -142,9 +141,9 @@ class DatabasesController extends AbstractController
|
||||
|
||||
$this->render('server/databases/index', [
|
||||
'is_create_database_shown' => $config->settings['ShowCreateDb'],
|
||||
'has_create_database_privileges' => $GLOBALS['is_create_db_priv'],
|
||||
'has_create_database_privileges' => UserPrivileges::$isCreateDatabase,
|
||||
'has_statistics' => $this->hasStatistics,
|
||||
'database_to_create' => $GLOBALS['db_to_create'],
|
||||
'database_to_create' => UserPrivileges::$databaseToCreate,
|
||||
'databases' => $databases['databases'],
|
||||
'total_statistics' => $databases['total_statistics'],
|
||||
'header_statistics' => $headerStatistics,
|
||||
|
||||
@ -20,6 +20,7 @@ use PhpMyAdmin\Table\Table;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
@ -363,7 +364,7 @@ final class SaveController extends AbstractController
|
||||
{
|
||||
$changed = false;
|
||||
|
||||
if (($GLOBALS['col_priv'] ?? false) && ($GLOBALS['is_reload_priv'] ?? false)) {
|
||||
if (UserPrivileges::$column && UserPrivileges::$isReload) {
|
||||
$this->dbi->selectDb('mysql');
|
||||
|
||||
// For Column specific privileges
|
||||
|
||||
@ -15,6 +15,7 @@ use PhpMyAdmin\SqlParser\Parser;
|
||||
use PhpMyAdmin\SqlParser\Statements\CreateStatement;
|
||||
use PhpMyAdmin\SqlParser\TokensList;
|
||||
use PhpMyAdmin\SqlParser\Utils\Routine;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
@ -163,7 +164,7 @@ class Routines
|
||||
*/
|
||||
public function backupPrivileges(): array
|
||||
{
|
||||
if (! $GLOBALS['proc_priv'] || ! $GLOBALS['is_reload_priv']) {
|
||||
if (! UserPrivileges::$routines || ! UserPrivileges::$isReload) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -219,7 +220,7 @@ class Routines
|
||||
// Default value
|
||||
$resultAdjust = false;
|
||||
|
||||
if ($GLOBALS['proc_priv'] && $GLOBALS['is_reload_priv']) {
|
||||
if (UserPrivileges::$routines && UserPrivileges::$isReload) {
|
||||
// Insert all the previous privileges
|
||||
// but with the new name and the new type
|
||||
foreach ($privilegesBackup as $priv) {
|
||||
|
||||
@ -90,13 +90,13 @@ class ListDatabase extends ListAbstract
|
||||
if ($likeDbName !== null) {
|
||||
$command .= " WHERE `SCHEMA_NAME` LIKE '" . $likeDbName . "'";
|
||||
}
|
||||
} elseif ($GLOBALS['dbs_to_test'] === false || $likeDbName !== null) {
|
||||
} elseif (UserPrivileges::$databasesToTest === false || $likeDbName !== null) {
|
||||
$command .= 'SHOW DATABASES';
|
||||
if ($likeDbName !== null) {
|
||||
$command .= " LIKE '" . $likeDbName . "'";
|
||||
}
|
||||
} else {
|
||||
foreach ($GLOBALS['dbs_to_test'] as $db) {
|
||||
foreach (UserPrivileges::$databasesToTest as $db) {
|
||||
$databaseList = array_merge(
|
||||
$databaseList,
|
||||
$this->retrieve($db),
|
||||
|
||||
@ -38,6 +38,7 @@ use PhpMyAdmin\Navigation\Nodes\NodeViewContainer;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
@ -249,7 +250,7 @@ class NavigationTree
|
||||
}
|
||||
|
||||
$prefixMap = [];
|
||||
if ($GLOBALS['dbs_to_test'] === false) {
|
||||
if (UserPrivileges::$databasesToTest === false) {
|
||||
$handle = $this->dbi->tryQuery('SHOW DATABASES');
|
||||
if ($handle !== false) {
|
||||
while ($database = $handle->fetchValue()) {
|
||||
@ -267,7 +268,7 @@ class NavigationTree
|
||||
}
|
||||
} else {
|
||||
$databases = [];
|
||||
foreach ($GLOBALS['dbs_to_test'] as $db) {
|
||||
foreach (UserPrivileges::$databasesToTest as $db) {
|
||||
$query = "SHOW DATABASES LIKE '" . $db . "'";
|
||||
$handle = $this->dbi->tryQuery($query);
|
||||
if ($handle === false) {
|
||||
|
||||
@ -14,6 +14,7 @@ use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Dbal\Connection;
|
||||
use PhpMyAdmin\Html\Generator;
|
||||
use PhpMyAdmin\Navigation\NodeType;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
@ -371,7 +372,7 @@ class Node
|
||||
return $this->getDataFromInfoSchema($pos, $searchClause);
|
||||
}
|
||||
|
||||
if ($GLOBALS['dbs_to_test'] === false) {
|
||||
if (UserPrivileges::$databasesToTest === false) {
|
||||
return $this->getDataFromShowDatabases($pos, $searchClause);
|
||||
}
|
||||
|
||||
@ -402,7 +403,7 @@ class Node
|
||||
return (int) $dbi->fetchValue($query);
|
||||
}
|
||||
|
||||
if ($GLOBALS['dbs_to_test'] === false) {
|
||||
if (UserPrivileges::$databasesToTest === false) {
|
||||
$query = 'SHOW DATABASES ';
|
||||
$query .= $this->getWhereClause('Database', $searchClause);
|
||||
|
||||
@ -432,7 +433,7 @@ class Node
|
||||
return (int) $dbi->fetchValue($query);
|
||||
}
|
||||
|
||||
if ($GLOBALS['dbs_to_test'] !== false) {
|
||||
if (UserPrivileges::$databasesToTest !== false) {
|
||||
$prefixMap = [];
|
||||
foreach ($this->getDatabasesToSearch($searchClause) as $db) {
|
||||
$query = 'SHOW DATABASES LIKE ' . $dbi->quoteString($db);
|
||||
@ -507,8 +508,8 @@ class Node
|
||||
$databases = ['%' . DatabaseInterface::getInstance()->escapeMysqlWildcards($searchClause) . '%'];
|
||||
} elseif (! empty($config->selectedServer['only_db'])) {
|
||||
$databases = $config->selectedServer['only_db'];
|
||||
} elseif (! empty($GLOBALS['dbs_to_test'])) {
|
||||
$databases = $GLOBALS['dbs_to_test'];
|
||||
} elseif (UserPrivileges::$databasesToTest !== false && UserPrivileges::$databasesToTest !== []) {
|
||||
$databases = UserPrivileges::$databasesToTest;
|
||||
}
|
||||
|
||||
sort($databases);
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Navigation\NodeType;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
|
||||
use function _pgettext;
|
||||
|
||||
@ -31,7 +32,7 @@ class NodeDatabaseContainer extends Node
|
||||
|
||||
parent::__construct($name, NodeType::Container);
|
||||
|
||||
if (! $GLOBALS['is_create_db_priv'] || Config::getInstance()->settings['ShowCreateDb'] === false) {
|
||||
if (! UserPrivileges::$isCreateDatabase || Config::getInstance()->settings['ShowCreateDb'] === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -175,7 +175,7 @@ class Normalization
|
||||
'max_rows' => intval($config->settings['MaxRows']),
|
||||
'char_editing' => $config->settings['CharEditing'],
|
||||
'attribute_types' => $this->dbi->types->getAttributes(),
|
||||
'privs_available' => $GLOBALS['col_priv'] && $GLOBALS['is_reload_priv'],
|
||||
'privs_available' => UserPrivileges::$column && UserPrivileges::$isReload,
|
||||
'max_length' => $this->dbi->getVersion() >= 50503 ? 1024 : 255,
|
||||
'charsets' => $charsetsList,
|
||||
]);
|
||||
|
||||
@ -292,9 +292,9 @@ class Operations
|
||||
public function adjustPrivilegesMoveDb(string $oldDb, DatabaseName $newDatabaseName): void
|
||||
{
|
||||
if (
|
||||
! $GLOBALS['db_priv'] || ! $GLOBALS['table_priv']
|
||||
|| ! $GLOBALS['col_priv'] || ! $GLOBALS['proc_priv']
|
||||
|| ! $GLOBALS['is_reload_priv']
|
||||
! UserPrivileges::$database || ! UserPrivileges::$table
|
||||
|| ! UserPrivileges::$column || ! UserPrivileges::$routines
|
||||
|| ! UserPrivileges::$isReload
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@ -335,9 +335,9 @@ class Operations
|
||||
public function adjustPrivilegesCopyDb(string $oldDb, DatabaseName $newDatabaseName): void
|
||||
{
|
||||
if (
|
||||
! $GLOBALS['db_priv'] || ! $GLOBALS['table_priv']
|
||||
|| ! $GLOBALS['col_priv'] || ! $GLOBALS['proc_priv']
|
||||
|| ! $GLOBALS['is_reload_priv']
|
||||
! UserPrivileges::$database || ! UserPrivileges::$table
|
||||
|| ! UserPrivileges::$column || ! UserPrivileges::$routines
|
||||
|| ! UserPrivileges::$isReload
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@ -741,7 +741,7 @@ class Operations
|
||||
string $newDb,
|
||||
string $newTable,
|
||||
): void {
|
||||
if (! $GLOBALS['table_priv'] || ! $GLOBALS['col_priv'] || ! $GLOBALS['is_reload_priv']) {
|
||||
if (! UserPrivileges::$table || ! UserPrivileges::$column || ! UserPrivileges::$isReload) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -777,7 +777,7 @@ class Operations
|
||||
*/
|
||||
public function adjustPrivilegesCopyTable(string $oldDb, string $oldTable, string $newDb, string $newTable): void
|
||||
{
|
||||
if (! $GLOBALS['table_priv'] || ! $GLOBALS['col_priv'] || ! $GLOBALS['is_reload_priv']) {
|
||||
if (! UserPrivileges::$table || ! UserPrivileges::$column || ! UserPrivileges::$isReload) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ use PhpMyAdmin\Query\Compatibility;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
@ -2608,7 +2609,7 @@ class Privileges
|
||||
|
||||
$response = ResponseRenderer::getInstance();
|
||||
if (! $response->isAjax() || ! empty($_REQUEST['ajax_page_request'])) {
|
||||
if ($GLOBALS['is_reload_priv']) {
|
||||
if (UserPrivileges::$isReload) {
|
||||
$flushnote = new Message(
|
||||
__(
|
||||
'Note: phpMyAdmin gets the users’ privileges directly '
|
||||
|
||||
@ -14,6 +14,7 @@ use PhpMyAdmin\Partitioning\TablePartitionDefinition;
|
||||
use PhpMyAdmin\Query\Compatibility;
|
||||
use PhpMyAdmin\StorageEngine;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function array_keys;
|
||||
@ -69,8 +70,6 @@ final class ColumnsDefinition
|
||||
array|null $selected = null,
|
||||
array|null $fieldsMeta = null,
|
||||
): array {
|
||||
$GLOBALS['col_priv'] ??= null;
|
||||
$GLOBALS['is_reload_priv'] ??= null;
|
||||
$GLOBALS['mime_map'] ??= null;
|
||||
|
||||
$regenerate = false;
|
||||
@ -357,7 +356,7 @@ final class ColumnsDefinition
|
||||
'max_rows' => intval($config->settings['MaxRows']),
|
||||
'char_editing' => $config->settings['CharEditing'] ?? null,
|
||||
'attribute_types' => $this->dbi->types->getAttributes(),
|
||||
'privs_available' => ($GLOBALS['col_priv'] ?? false) && ($GLOBALS['is_reload_priv'] ?? false),
|
||||
'privs_available' => UserPrivileges::$column && UserPrivileges::$isReload,
|
||||
'max_length' => $this->dbi->getVersion() >= 50503 ? 1024 : 255,
|
||||
'have_partitioning' => Partition::havePartitioning(),
|
||||
'disable_is' => $config->selectedServer['DisableIS'],
|
||||
|
||||
18
src/UserPrivileges.php
Normal file
18
src/UserPrivileges.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin;
|
||||
|
||||
final class UserPrivileges
|
||||
{
|
||||
public static bool $database = false;
|
||||
public static bool $table = false;
|
||||
public static bool $column = false;
|
||||
public static bool $routines = false;
|
||||
public static bool $isReload = false;
|
||||
public static bool $isCreateDatabase = false;
|
||||
public static string $databaseToCreate = '';
|
||||
/** @var string[]|false */
|
||||
public static array|bool $databasesToTest = false;
|
||||
}
|
||||
@ -15,6 +15,7 @@ use PhpMyAdmin\LanguageManager;
|
||||
use PhpMyAdmin\SqlParser\Translator;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Utils\HttpRequest;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionClass;
|
||||
@ -77,6 +78,16 @@ abstract class AbstractTestCase extends TestCase
|
||||
Current::$table = '';
|
||||
$GLOBALS['sql_query'] = '';
|
||||
|
||||
UserPrivileges::$column = false;
|
||||
UserPrivileges::$database = false;
|
||||
UserPrivileges::$table = false;
|
||||
UserPrivileges::$column = false;
|
||||
UserPrivileges::$routines = false;
|
||||
UserPrivileges::$isReload = false;
|
||||
UserPrivileges::$isCreateDatabase = false;
|
||||
UserPrivileges::$databaseToCreate = '';
|
||||
UserPrivileges::$databasesToTest = false;
|
||||
|
||||
// Config before DBI
|
||||
$this->setGlobalConfig();
|
||||
Cache::purge();
|
||||
|
||||
@ -8,6 +8,7 @@ use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\ShowGrants;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(CheckUserPrivileges::class)]
|
||||
@ -24,11 +25,11 @@ class CheckUserPrivilegesTest extends AbstractTestCase
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface();
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
$GLOBALS['col_priv'] = false;
|
||||
$GLOBALS['db_priv'] = false;
|
||||
$GLOBALS['proc_priv'] = false;
|
||||
$GLOBALS['table_priv'] = false;
|
||||
$GLOBALS['is_reload_priv'] = false;
|
||||
UserPrivileges::$column = false;
|
||||
UserPrivileges::$database = false;
|
||||
UserPrivileges::$routines = false;
|
||||
UserPrivileges::$table = false;
|
||||
UserPrivileges::$isReload = false;
|
||||
|
||||
$this->checkUserPrivileges = new CheckUserPrivileges(DatabaseInterface::getInstance());
|
||||
}
|
||||
@ -44,13 +45,10 @@ class CheckUserPrivilegesTest extends AbstractTestCase
|
||||
// call the to-be-tested function
|
||||
$this->checkUserPrivileges->checkRequiredPrivilegesForAdjust($showGrants);
|
||||
|
||||
$this->assertTrue($GLOBALS['col_priv']);
|
||||
|
||||
$this->assertTrue($GLOBALS['db_priv']);
|
||||
|
||||
$this->assertTrue($GLOBALS['proc_priv']);
|
||||
|
||||
$this->assertTrue($GLOBALS['table_priv']);
|
||||
$this->assertTrue(UserPrivileges::$column);
|
||||
$this->assertTrue(UserPrivileges::$database);
|
||||
$this->assertTrue(UserPrivileges::$routines);
|
||||
$this->assertTrue(UserPrivileges::$table);
|
||||
|
||||
// re-initialise the privileges
|
||||
$this->setUp();
|
||||
@ -61,13 +59,10 @@ class CheckUserPrivilegesTest extends AbstractTestCase
|
||||
// call the to-be-tested function
|
||||
$this->checkUserPrivileges->checkRequiredPrivilegesForAdjust($showGrants);
|
||||
|
||||
$this->assertTrue($GLOBALS['col_priv']);
|
||||
|
||||
$this->assertTrue($GLOBALS['db_priv']);
|
||||
|
||||
$this->assertTrue($GLOBALS['proc_priv']);
|
||||
|
||||
$this->assertTrue($GLOBALS['table_priv']);
|
||||
$this->assertTrue(UserPrivileges::$column);
|
||||
$this->assertTrue(UserPrivileges::$database);
|
||||
$this->assertTrue(UserPrivileges::$routines);
|
||||
$this->assertTrue(UserPrivileges::$table);
|
||||
|
||||
// re-initialise the privileges
|
||||
$this->setUp();
|
||||
@ -78,13 +73,10 @@ class CheckUserPrivilegesTest extends AbstractTestCase
|
||||
// call the to-be-tested function
|
||||
$this->checkUserPrivileges->checkRequiredPrivilegesForAdjust($showGrants);
|
||||
|
||||
$this->assertTrue($GLOBALS['col_priv']);
|
||||
|
||||
$this->assertTrue($GLOBALS['db_priv']);
|
||||
|
||||
$this->assertTrue($GLOBALS['proc_priv']);
|
||||
|
||||
$this->assertTrue($GLOBALS['table_priv']);
|
||||
$this->assertTrue(UserPrivileges::$column);
|
||||
$this->assertTrue(UserPrivileges::$database);
|
||||
$this->assertTrue(UserPrivileges::$routines);
|
||||
$this->assertTrue(UserPrivileges::$table);
|
||||
|
||||
// re-initialise the privileges
|
||||
$this->setUp();
|
||||
@ -95,12 +87,9 @@ class CheckUserPrivilegesTest extends AbstractTestCase
|
||||
// call the to-be-tested function
|
||||
$this->checkUserPrivileges->checkRequiredPrivilegesForAdjust($showGrants);
|
||||
|
||||
$this->assertFalse($GLOBALS['col_priv']);
|
||||
|
||||
$this->assertTrue($GLOBALS['db_priv']);
|
||||
|
||||
$this->assertFalse($GLOBALS['proc_priv']);
|
||||
|
||||
$this->assertFalse($GLOBALS['table_priv']);
|
||||
$this->assertFalse(UserPrivileges::$column);
|
||||
$this->assertTrue(UserPrivileges::$database);
|
||||
$this->assertFalse(UserPrivileges::$routines);
|
||||
$this->assertFalse(UserPrivileges::$table);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(AddNewPrimaryController::class)]
|
||||
@ -23,7 +24,7 @@ class AddNewPrimaryControllerTest extends AbstractTestCase
|
||||
public function testDefault(): void
|
||||
{
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
$GLOBALS['col_priv'] = false;
|
||||
UserPrivileges::$column = false;
|
||||
Current::$database = 'test_db';
|
||||
Current::$table = 'test_table';
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(CreateNewColumnController::class)]
|
||||
@ -23,7 +24,7 @@ class CreateNewColumnControllerTest extends AbstractTestCase
|
||||
public function testDefault(): void
|
||||
{
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
$GLOBALS['col_priv'] = false;
|
||||
UserPrivileges::$column = false;
|
||||
Current::$database = 'test_db';
|
||||
Current::$table = 'test_table';
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
use function __;
|
||||
@ -80,7 +81,7 @@ class DatabasesControllerTest extends AbstractTestCase
|
||||
$controller = new DatabasesController($response, $template, DatabaseInterface::getInstance());
|
||||
|
||||
$config->settings['ShowCreateDb'] = true;
|
||||
$GLOBALS['is_create_db_priv'] = true;
|
||||
UserPrivileges::$isCreateDatabase = true;
|
||||
$_REQUEST['statistics'] = '1';
|
||||
$_REQUEST['sort_by'] = 'SCHEMA_TABLES';
|
||||
$_REQUEST['sort_order'] = 'desc';
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Dbal\Connection;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Types;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
@ -36,8 +37,8 @@ class RoutinesTest extends AbstractTestCase
|
||||
$config->settings['ActionLinksMode'] = 'icons';
|
||||
Current::$database = 'db';
|
||||
Current::$table = 'table';
|
||||
$GLOBALS['proc_priv'] = false;
|
||||
$GLOBALS['is_reload_priv'] = false;
|
||||
UserPrivileges::$routines = false;
|
||||
UserPrivileges::$isReload = false;
|
||||
$GLOBALS['errors'] = [];
|
||||
|
||||
$this->routines = new Routines(DatabaseInterface::getInstance());
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\Navigation\Nodes\Node;
|
||||
use PhpMyAdmin\Navigation\NodeType;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use ReflectionMethod;
|
||||
|
||||
@ -398,7 +399,7 @@ final class NodeTest extends AbstractTestCase
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$config->selectedServer['DisableIS'] = true;
|
||||
$GLOBALS['dbs_to_test'] = false;
|
||||
UserPrivileges::$databasesToTest = false;
|
||||
$config->settings['NavigationTreeEnableGrouping'] = true;
|
||||
$config->settings['FirstLevelNavigationItems'] = 10;
|
||||
$config->settings['NavigationTreeDbSeparator'] = '_';
|
||||
@ -491,7 +492,7 @@ final class NodeTest extends AbstractTestCase
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$config->selectedServer['DisableIS'] = true;
|
||||
$GLOBALS['dbs_to_test'] = false;
|
||||
UserPrivileges::$databasesToTest = false;
|
||||
$config->settings['NavigationTreeEnableGrouping'] = true;
|
||||
|
||||
$node = new Node('node');
|
||||
|
||||
@ -17,6 +17,7 @@ use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\Types;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use stdClass;
|
||||
|
||||
@ -124,7 +125,7 @@ class NormalizationTest extends AbstractTestCase
|
||||
$config = Config::getInstance();
|
||||
$config->settings['BrowseMIME'] = true;
|
||||
$config->settings['MaxRows'] = 25;
|
||||
$GLOBALS['col_priv'] = false;
|
||||
UserPrivileges::$column = false;
|
||||
$config->selectedServer['DisableIS'] = false;
|
||||
DatabaseInterface::$instance = $this->dbi;
|
||||
$db = 'testdb';
|
||||
|
||||
@ -21,6 +21,7 @@ use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PhpMyAdmin\Util;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
@ -1464,7 +1465,7 @@ class PrivilegesTest extends AbstractTestCase
|
||||
{
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
$GLOBALS['lang'] = 'en';
|
||||
$GLOBALS['is_reload_priv'] = true;
|
||||
UserPrivileges::$isReload = true;
|
||||
|
||||
$dummyDbi = $this->createDbiDummy();
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
|
||||
@ -12,6 +12,7 @@ use PhpMyAdmin\Table\ColumnsDefinition;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\FieldHelper;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\UserPrivileges;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
@ -76,8 +77,8 @@ SQL;
|
||||
|
||||
Current::$database = 'sakila';
|
||||
Current::$table = 'actor';
|
||||
$GLOBALS['col_priv'] = true;
|
||||
$GLOBALS['is_reload_priv'] = true;
|
||||
UserPrivileges::$column = true;
|
||||
UserPrivileges::$isReload = true;
|
||||
$GLOBALS['mime_map'] = null;
|
||||
|
||||
$actual = $columnsDefinition->displayForm('/table/structure/save', 1, ['actor_id'], [$columnMeta]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user