diff --git a/libraries/classes/Controllers/Database/PrivilegesController.php b/libraries/classes/Controllers/Database/PrivilegesController.php index 2776c329c1..811dd43f52 100644 --- a/libraries/classes/Controllers/Database/PrivilegesController.php +++ b/libraries/classes/Controllers/Database/PrivilegesController.php @@ -13,6 +13,8 @@ use PhpMyAdmin\Server\Privileges; use PhpMyAdmin\Template; use PhpMyAdmin\Util; +use function mb_strtolower; + /** * Controller for database privileges */ @@ -37,7 +39,8 @@ class PrivilegesController extends AbstractController } /** - * @param array $params Request parameters + * @param string[] $params Request parameters + * @psalm-param array{checkprivsdb: string} $params */ public function __invoke(array $params): string { @@ -45,14 +48,19 @@ class PrivilegesController extends AbstractController $scriptName = Util::getScriptNameForOption($cfg['DefaultTabDatabase'], 'database'); + $db = $params['checkprivsdb']; + if ($this->dbi->getLowerCaseNames() === '1') { + $db = mb_strtolower($params['checkprivsdb']); + } + $privileges = []; if ($this->dbi->isSuperUser()) { - $privileges = $this->privileges->getAllPrivileges($params['checkprivsdb']); + $privileges = $this->privileges->getAllPrivileges($db); } return $this->template->render('database/privileges/index', [ 'is_superuser' => $this->dbi->isSuperUser(), - 'db' => $params['checkprivsdb'], + 'db' => $db, 'database_url' => $scriptName, 'text_dir' => $text_dir, 'is_createuser' => $this->dbi->isCreateUser(), diff --git a/libraries/classes/Controllers/Server/PrivilegesController.php b/libraries/classes/Controllers/Server/PrivilegesController.php index b8540fb778..eb0bf43a52 100644 --- a/libraries/classes/Controllers/Server/PrivilegesController.php +++ b/libraries/classes/Controllers/Server/PrivilegesController.php @@ -29,7 +29,6 @@ use function is_string; use function ob_get_clean; use function ob_start; use function str_replace; -use function strtolower; use function urlencode; /** @@ -395,10 +394,10 @@ class PrivilegesController extends AbstractController $this->response->addHTML( $serverPrivileges->getHtmlForAddUser(Util::escapeMysqlWildcards(is_string($dbname) ? $dbname : '')) ); - } elseif (isset($_GET['checkprivsdb'])) { - if (isset($_GET['checkprivstable'])) { + } elseif (isset($_GET['checkprivsdb']) && is_string($_GET['checkprivsdb'])) { + if (isset($_GET['checkprivstable']) && is_string($_GET['checkprivstable'])) { $this->response->addHTML($tableController([ - 'checkprivsdb' => strtolower($_GET['checkprivsdb']), + 'checkprivsdb' => $_GET['checkprivsdb'], 'checkprivstable' => $_GET['checkprivstable'], ])); $this->render('export_modal'); @@ -408,7 +407,7 @@ class PrivilegesController extends AbstractController return; } else { - $this->response->addHTML($databaseController(['checkprivsdb' => strtolower($_GET['checkprivsdb'])])); + $this->response->addHTML($databaseController(['checkprivsdb' => $_GET['checkprivsdb']])); $this->render('export_modal'); } } else { diff --git a/libraries/classes/Controllers/Table/PrivilegesController.php b/libraries/classes/Controllers/Table/PrivilegesController.php index 8a33437d5a..37e5379a19 100644 --- a/libraries/classes/Controllers/Table/PrivilegesController.php +++ b/libraries/classes/Controllers/Table/PrivilegesController.php @@ -13,6 +13,8 @@ use PhpMyAdmin\Server\Privileges; use PhpMyAdmin\Template; use PhpMyAdmin\Util; +use function mb_strtolower; + /** * Controller for table privileges */ @@ -38,7 +40,8 @@ class PrivilegesController extends AbstractController } /** - * @param array $params Request parameters + * @param string[] $params Request parameters + * @psalm-param array{checkprivsdb: string, checkprivstable: string} $params */ public function __invoke(array $params): string { @@ -46,14 +49,21 @@ class PrivilegesController extends AbstractController $scriptName = Util::getScriptNameForOption($cfg['DefaultTabTable'], 'table'); + $db = $params['checkprivsdb']; + $table = $params['checkprivstable']; + if ($this->dbi->getLowerCaseNames() === '1') { + $db = mb_strtolower($params['checkprivsdb']); + $table = mb_strtolower($params['checkprivstable']); + } + $privileges = []; if ($this->dbi->isSuperUser()) { - $privileges = $this->privileges->getAllPrivileges($params['checkprivsdb'], $params['checkprivstable']); + $privileges = $this->privileges->getAllPrivileges($db, $table); } return $this->template->render('table/privileges/index', [ - 'db' => $params['checkprivsdb'], - 'table' => $params['checkprivstable'], + 'db' => $db, + 'table' => $table, 'is_superuser' => $this->dbi->isSuperUser(), 'table_url' => $scriptName, 'text_dir' => $text_dir, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 701d4ab7fe..807538fa29 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1055,11 +1055,6 @@ parameters: count: 6 path: libraries/classes/Controllers/Database/OperationsController.php - - - message: "#^Method PhpMyAdmin\\\\Controllers\\\\Database\\\\PrivilegesController\\:\\:__invoke\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#" - count: 1 - path: libraries/classes/Controllers/Database/PrivilegesController.php - - message: "#^Cannot access offset non\\-empty\\-string on mixed\\.$#" count: 1 @@ -1520,11 +1515,6 @@ parameters: count: 1 path: libraries/classes/Controllers/Table/OperationsController.php - - - message: "#^Method PhpMyAdmin\\\\Controllers\\\\Table\\\\PrivilegesController\\:\\:__invoke\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#" - count: 1 - path: libraries/classes/Controllers/Table/PrivilegesController.php - - message: "#^Cannot cast mixed to string\\.$#" count: 1 @@ -1840,11 +1830,6 @@ parameters: count: 1 path: libraries/classes/Core.php - - - message: "#^Offset 'pass'\\|'port'\\|'user' does not exist on array\\{scheme\\?\\: string, host\\: non\\-empty\\-string, port\\?\\: int, user\\?\\: string, pass\\?\\: string, path\\?\\: string, query\\?\\: string, fragment\\?\\: string\\}\\.$#" - count: 1 - path: libraries/classes/Core.php - - message: "#^Method PhpMyAdmin\\\\CreateAddField\\:\\:buildColumnCreationStatement\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ada8b0924b..be430c4b4b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1313,11 +1313,6 @@ $_error - - - $params['checkprivsdb'] - - $_POST['db'] @@ -2490,9 +2485,7 @@ - - $_GET['checkprivsdb'] - $_GET['checkprivsdb'] + $_POST['userGroup'] $db $db @@ -3287,12 +3280,6 @@ $query - - - $params['checkprivsdb'] - $params['checkprivstable'] - - $_REQUEST['db']