diff options
35 files changed, 374 insertions, 556 deletions
diff --git a/libraries/classes/Controllers/Database/DesignerController.php b/libraries/classes/Controllers/Database/DesignerController.php index bc0d9572d7..45f66c0230 100644 --- a/libraries/classes/Controllers/Database/DesignerController.php +++ b/libraries/classes/Controllers/Database/DesignerController.php @@ -55,7 +55,6 @@ class DesignerController extends AbstractController $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['num_tables'] = $GLOBALS['num_tables'] ?? null; $GLOBALS['total_num_tables'] = $GLOBALS['total_num_tables'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['tooltip_truename'] = $GLOBALS['tooltip_truename'] ?? null; $GLOBALS['tooltip_aliasname'] = $GLOBALS['tooltip_aliasname'] ?? null; $GLOBALS['pos'] = $GLOBALS['pos'] ?? null; @@ -239,12 +238,11 @@ class DesignerController extends AbstractController [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],,, + $GLOBALS['total_num_tables'],,, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part'] ?? ''); + ] = Util::getDbInfo($request, $GLOBALS['db']); // Embed some data into HTML, later it will be read // by designer/init.js and converted to JS variables. diff --git a/libraries/classes/Controllers/Database/EventsController.php b/libraries/classes/Controllers/Database/EventsController.php index b0d6c70632..d697dc01ef 100644 --- a/libraries/classes/Controllers/Database/EventsController.php +++ b/libraries/classes/Controllers/Database/EventsController.php @@ -39,7 +39,6 @@ final class EventsController extends AbstractController $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['num_tables'] = $GLOBALS['num_tables'] ?? null; $GLOBALS['total_num_tables'] = $GLOBALS['total_num_tables'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['errors'] = $GLOBALS['errors'] ?? null; $GLOBALS['text_dir'] = $GLOBALS['text_dir'] ?? null; $GLOBALS['tooltip_truename'] = $GLOBALS['tooltip_truename'] ?? null; @@ -62,12 +61,11 @@ final class EventsController extends AbstractController [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],,, + $GLOBALS['total_num_tables'],,, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part'] ?? ''); + ] = Util::getDbInfo($request, $GLOBALS['db']); } elseif (strlen($GLOBALS['db']) > 0) { $this->dbi->selectDb($GLOBALS['db']); } diff --git a/libraries/classes/Controllers/Database/ExportController.php b/libraries/classes/Controllers/Database/ExportController.php index 76444c327a..227b5ce876 100644 --- a/libraries/classes/Controllers/Database/ExportController.php +++ b/libraries/classes/Controllers/Database/ExportController.php @@ -41,7 +41,6 @@ final class ExportController extends AbstractController public function __invoke(ServerRequest $request): void { - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['urlParams'] = $GLOBALS['urlParams'] ?? null; $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['num_tables'] = $GLOBALS['num_tables'] ?? null; @@ -59,10 +58,6 @@ final class ExportController extends AbstractController $this->addScriptFiles(['export.js']); - // $sub_part is used in Util::getDbInfo() to see if we are coming from - // /database/export, in which case we don't obey $cfg['MaxTableList'] - $GLOBALS['sub_part'] = '_export'; - $this->checkParameters(['db']); $GLOBALS['errorUrl'] = Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database'); @@ -77,12 +72,11 @@ final class ExportController extends AbstractController [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],,, + $GLOBALS['total_num_tables'],,, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part']); + ] = Util::getDbInfo($request, $GLOBALS['db'], false); // exit if no tables in db found if ($GLOBALS['num_tables'] < 1) { diff --git a/libraries/classes/Controllers/Database/ImportController.php b/libraries/classes/Controllers/Database/ImportController.php index 2755939d3c..b1585a39a7 100644 --- a/libraries/classes/Controllers/Database/ImportController.php +++ b/libraries/classes/Controllers/Database/ImportController.php @@ -43,7 +43,6 @@ final class ImportController extends AbstractController $GLOBALS['tooltip_truename'] = $GLOBALS['tooltip_truename'] ?? null; $GLOBALS['tooltip_aliasname'] = $GLOBALS['tooltip_aliasname'] ?? null; $GLOBALS['pos'] = $GLOBALS['pos'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['SESSION_KEY'] = $GLOBALS['SESSION_KEY'] ?? null; $GLOBALS['errorUrl'] = $GLOBALS['errorUrl'] ?? null; @@ -65,12 +64,11 @@ final class ImportController extends AbstractController [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],,, + $GLOBALS['total_num_tables'],,, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part'] ?? ''); + ] = Util::getDbInfo($request, $GLOBALS['db']); [$GLOBALS['SESSION_KEY'], $uploadId] = Ajax::uploadProgressSetup(); diff --git a/libraries/classes/Controllers/Database/Operations/CollationController.php b/libraries/classes/Controllers/Database/Operations/CollationController.php index 2d6d32d110..c50420fe90 100644 --- a/libraries/classes/Controllers/Database/Operations/CollationController.php +++ b/libraries/classes/Controllers/Database/Operations/CollationController.php @@ -69,7 +69,7 @@ final class CollationController extends AbstractController * Changes tables charset if requested by the user */ if ($request->getParsedBodyParam('change_all_tables_collations') === 'on') { - [$tables] = Util::getDbInfo($GLOBALS['db'], ''); + [$tables] = Util::getDbInfo($request, $GLOBALS['db']); foreach ($tables as ['Name' => $tableName]) { if ($this->dbi->getTable($GLOBALS['db'], $tableName)->isView()) { // Skip views, we can not change the collation of a view. diff --git a/libraries/classes/Controllers/Database/OperationsController.php b/libraries/classes/Controllers/Database/OperationsController.php index 031a8096f4..9b793f55ee 100644 --- a/libraries/classes/Controllers/Database/OperationsController.php +++ b/libraries/classes/Controllers/Database/OperationsController.php @@ -80,7 +80,6 @@ class OperationsController extends AbstractController $GLOBALS['urlParams'] = $GLOBALS['urlParams'] ?? null; $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['total_num_tables'] = $GLOBALS['total_num_tables'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['tooltip_truename'] = $GLOBALS['tooltip_truename'] ?? null; $GLOBALS['db_collation'] = $GLOBALS['db_collation'] ?? null; $GLOBALS['tooltip_aliasname'] = $GLOBALS['tooltip_aliasname'] ?? null; @@ -286,19 +285,15 @@ class OperationsController extends AbstractController $GLOBALS['urlParams']['goto'] = Url::getFromRoute('/database/operations'); - // Gets the database structure - $GLOBALS['sub_part'] = '_structure'; - [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],, + $GLOBALS['total_num_tables'],, $isSystemSchema, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part']); + ] = Util::getDbInfo($request, $GLOBALS['db']); $oldMessage = ''; if (isset($GLOBALS['message'])) { diff --git a/libraries/classes/Controllers/Database/PrivilegesController.php b/libraries/classes/Controllers/Database/PrivilegesController.php index 9f01338252..5bed75c150 100644 --- a/libraries/classes/Controllers/Database/PrivilegesController.php +++ b/libraries/classes/Controllers/Database/PrivilegesController.php @@ -89,19 +89,16 @@ class PrivilegesController extends AbstractController )->getDisplay()); } - // Gets the database structure - $GLOBALS['sub_part'] = '_structure'; ob_start(); [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],,, + $GLOBALS['total_num_tables'],,, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($db->getName(), $GLOBALS['sub_part']); + ] = Util::getDbInfo($request, $db->getName()); $content = ob_get_clean(); $this->response->addHTML($content . "\n"); diff --git a/libraries/classes/Controllers/Database/QueryByExampleController.php b/libraries/classes/Controllers/Database/QueryByExampleController.php index 3cb8996788..06019397c6 100644 --- a/libraries/classes/Controllers/Database/QueryByExampleController.php +++ b/libraries/classes/Controllers/Database/QueryByExampleController.php @@ -46,7 +46,6 @@ class QueryByExampleController extends AbstractController $GLOBALS['savedSearch'] = $GLOBALS['savedSearch'] ?? null; $GLOBALS['currentSearchId'] = $GLOBALS['currentSearchId'] ?? null; $GLOBALS['goto'] = $GLOBALS['goto'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['num_tables'] = $GLOBALS['num_tables'] ?? null; $GLOBALS['total_num_tables'] = $GLOBALS['total_num_tables'] ?? null; @@ -145,8 +144,6 @@ class QueryByExampleController extends AbstractController } } - $GLOBALS['sub_part'] = '_qbe'; - $this->checkParameters(['db']); $GLOBALS['errorUrl'] = Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database'); @@ -161,12 +158,11 @@ class QueryByExampleController extends AbstractController [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],,, + $GLOBALS['total_num_tables'],,, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part']); + ] = Util::getDbInfo($request, $GLOBALS['db']); $databaseQbe = new Qbe( $this->relation, diff --git a/libraries/classes/Controllers/Database/RoutinesController.php b/libraries/classes/Controllers/Database/RoutinesController.php index fb39aa7545..e569e90072 100644 --- a/libraries/classes/Controllers/Database/RoutinesController.php +++ b/libraries/classes/Controllers/Database/RoutinesController.php @@ -50,7 +50,6 @@ class RoutinesController extends AbstractController $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['num_tables'] = $GLOBALS['num_tables'] ?? null; $GLOBALS['total_num_tables'] = $GLOBALS['total_num_tables'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['tooltip_truename'] = $GLOBALS['tooltip_truename'] ?? null; $GLOBALS['tooltip_aliasname'] = $GLOBALS['tooltip_aliasname'] ?? null; $GLOBALS['pos'] = $GLOBALS['pos'] ?? null; @@ -91,12 +90,11 @@ class RoutinesController extends AbstractController [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],,, + $GLOBALS['total_num_tables'],,, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part'] ?? ''); + ] = Util::getDbInfo($request, $GLOBALS['db']); } } elseif (strlen($GLOBALS['db']) > 0) { $this->dbi->selectDb($GLOBALS['db']); diff --git a/libraries/classes/Controllers/Database/SearchController.php b/libraries/classes/Controllers/Database/SearchController.php index ee27a48b5a..07ab737a03 100644 --- a/libraries/classes/Controllers/Database/SearchController.php +++ b/libraries/classes/Controllers/Database/SearchController.php @@ -34,7 +34,6 @@ class SearchController extends AbstractController $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['num_tables'] = $GLOBALS['num_tables'] ?? null; $GLOBALS['total_num_tables'] = $GLOBALS['total_num_tables'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['tooltip_truename'] = $GLOBALS['tooltip_truename'] ?? null; $GLOBALS['tooltip_aliasname'] = $GLOBALS['tooltip_aliasname'] ?? null; $GLOBALS['pos'] = $GLOBALS['pos'] ?? null; @@ -70,12 +69,11 @@ class SearchController extends AbstractController [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],,, + $GLOBALS['total_num_tables'],,, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part'] ?? ''); + ] = Util::getDbInfo($request, $GLOBALS['db']); } // Main search form has been submitted, get results diff --git a/libraries/classes/Controllers/Database/Structure/RealRowCountController.php b/libraries/classes/Controllers/Database/Structure/RealRowCountController.php index 7b8364d36f..7800ccd991 100644 --- a/libraries/classes/Controllers/Database/Structure/RealRowCountController.php +++ b/libraries/classes/Controllers/Database/Structure/RealRowCountController.php @@ -46,7 +46,7 @@ final class RealRowCountController extends AbstractController return; } - [$tables] = Util::getDbInfo($GLOBALS['db'], '_structure'); + [$tables] = Util::getDbInfo($request, $GLOBALS['db']); // If there is a request to update all table's row count. if (! isset($parameters['real_row_count_all'])) { diff --git a/libraries/classes/Controllers/Database/StructureController.php b/libraries/classes/Controllers/Database/StructureController.php index 0efc2c1f41..b309d06e67 100644 --- a/libraries/classes/Controllers/Database/StructureController.php +++ b/libraries/classes/Controllers/Database/StructureController.php @@ -111,20 +111,18 @@ class StructureController extends AbstractController } /** - * Retrieves database information for further use - * - * @param string $subPart Page part name + * Retrieves database information for further use. */ - private function getDatabaseInfo(string $subPart): void + private function getDatabaseInfo(ServerRequest $request): void { [ $tables, $numTables, - $totalNumTables,, + $totalNumTables, $isShowStats, $dbIsSystemSchema,,, $position, - ] = Util::getDbInfo($GLOBALS['db'], $subPart); + ] = Util::getDbInfo($request, $GLOBALS['db']); $this->tables = $tables; $this->numTables = $numTables; @@ -155,7 +153,7 @@ class StructureController extends AbstractController $this->addScriptFiles(['database/structure.js', 'table/change.js']); // Gets the database structure - $this->getDatabaseInfo('_structure'); + $this->getDatabaseInfo($request); // Checks if there are any tables to be shown on current page. // If there are no tables, the user is redirected to the last page diff --git a/libraries/classes/Controllers/Database/TrackingController.php b/libraries/classes/Controllers/Database/TrackingController.php index d09184be4a..4fe2fb9d56 100644 --- a/libraries/classes/Controllers/Database/TrackingController.php +++ b/libraries/classes/Controllers/Database/TrackingController.php @@ -51,7 +51,6 @@ class TrackingController extends AbstractController $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['num_tables'] = $GLOBALS['num_tables'] ?? null; $GLOBALS['total_num_tables'] = $GLOBALS['total_num_tables'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['pos'] = $GLOBALS['pos'] ?? null; $GLOBALS['tooltip_truename'] = $GLOBALS['tooltip_truename'] ?? null; $GLOBALS['tooltip_aliasname'] = $GLOBALS['tooltip_aliasname'] ?? null; @@ -71,19 +70,15 @@ class TrackingController extends AbstractController $GLOBALS['urlParams']['goto'] = Url::getFromRoute('/table/tracking'); $GLOBALS['urlParams']['back'] = Url::getFromRoute('/database/tracking'); - // Get the database structure - $GLOBALS['sub_part'] = '_structure'; - [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],, + $GLOBALS['total_num_tables'],, $isSystemSchema, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part']); + ] = Util::getDbInfo($request, $GLOBALS['db']); if (isset($_POST['delete_tracking'], $_POST['table'])) { Tracker::deleteTracking($GLOBALS['db'], $_POST['table']); diff --git a/libraries/classes/Controllers/Database/TriggersController.php b/libraries/classes/Controllers/Database/TriggersController.php index 8d964bd509..5ce1506a0a 100644 --- a/libraries/classes/Controllers/Database/TriggersController.php +++ b/libraries/classes/Controllers/Database/TriggersController.php @@ -44,7 +44,6 @@ class TriggersController extends AbstractController $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['num_tables'] = $GLOBALS['num_tables'] ?? null; $GLOBALS['total_num_tables'] = $GLOBALS['total_num_tables'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['tooltip_truename'] = $GLOBALS['tooltip_truename'] ?? null; $GLOBALS['tooltip_aliasname'] = $GLOBALS['tooltip_aliasname'] ?? null; $GLOBALS['pos'] = $GLOBALS['pos'] ?? null; @@ -81,12 +80,11 @@ class TriggersController extends AbstractController [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],,, + $GLOBALS['total_num_tables'],,, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part'] ?? ''); + ] = Util::getDbInfo($request, $GLOBALS['db']); } } elseif (strlen($GLOBALS['db']) > 0) { $this->dbi->selectDb($GLOBALS['db']); diff --git a/libraries/classes/Controllers/Server/BinlogController.php b/libraries/classes/Controllers/Server/BinlogController.php index 598c1087e1..2b69bbd8a7 100644 --- a/libraries/classes/Controllers/Server/BinlogController.php +++ b/libraries/classes/Controllers/Server/BinlogController.php @@ -44,33 +44,27 @@ class BinlogController extends AbstractController public function __invoke(ServerRequest $request): void { - $GLOBALS['errorUrl'] = $GLOBALS['errorUrl'] ?? null; + $log = $request->getParsedBodyParam('log'); + $position = (int) $request->getParsedBodyParam('pos', 0); - $params = [ - 'log' => $_POST['log'] ?? null, - 'pos' => $_POST['pos'] ?? null, - 'is_full_query' => $_POST['is_full_query'] ?? null, - ]; $GLOBALS['errorUrl'] = Url::getFromRoute('/'); if ($this->dbi->isSuperUser()) { $this->dbi->selectDb('mysql'); } - $position = ! empty($params['pos']) ? (int) $params['pos'] : 0; - $urlParams = []; - if (isset($params['log']) && array_key_exists($params['log'], $this->binaryLogs)) { - $urlParams['log'] = $params['log']; + if (array_key_exists($log, $this->binaryLogs)) { + $urlParams['log'] = $log; } $isFullQuery = false; - if (! empty($params['is_full_query'])) { + if ($request->hasBodyParam('is_full_query')) { $isFullQuery = true; $urlParams['is_full_query'] = 1; } - $sqlQuery = $this->getSqlQuery($params['log'] ?? '', $position, (int) $GLOBALS['cfg']['MaxRows']); + $sqlQuery = $this->getSqlQuery($log ?? '', $position, (int) $GLOBALS['cfg']['MaxRows']); $result = $this->dbi->query($sqlQuery); $numRows = $result->numRows(); @@ -99,7 +93,7 @@ class BinlogController extends AbstractController $this->render('server/binlog/index', [ 'url_params' => $urlParams, 'binary_logs' => $this->binaryLogs, - 'log' => $params['log'], + 'log' => $log, 'sql_message' => Generator::getMessage(Message::success(), $sqlQuery), 'values' => $values, 'has_previous' => $position > 0, @@ -123,7 +117,7 @@ class BinlogController extends AbstractController int $maxRows ): string { $sqlQuery = 'SHOW BINLOG EVENTS'; - if (! empty($log)) { + if ($log !== '') { $sqlQuery .= ' IN \'' . $log . '\''; } diff --git a/libraries/classes/Controllers/Server/PrivilegesController.php b/libraries/classes/Controllers/Server/PrivilegesController.php index 943c8e3741..cb72b78166 100644 --- a/libraries/classes/Controllers/Server/PrivilegesController.php +++ b/libraries/classes/Controllers/Server/PrivilegesController.php @@ -73,7 +73,6 @@ class PrivilegesController extends AbstractController $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['num_tables'] = $GLOBALS['num_tables'] ?? null; $GLOBALS['total_num_tables'] = $GLOBALS['total_num_tables'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['tooltip_truename'] = $GLOBALS['tooltip_truename'] ?? null; $GLOBALS['tooltip_aliasname'] = $GLOBALS['tooltip_aliasname'] ?? null; $GLOBALS['pos'] = $GLOBALS['pos'] ?? null; diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index e0cf459d11..10d83dd87d 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -27,6 +27,8 @@ use PhpMyAdmin\Util; use function __; use function count; use function implode; +use function is_array; +use function is_string; use function mb_strstr; use function mb_strtolower; use function mb_strtoupper; @@ -161,7 +163,7 @@ class OperationsController extends AbstractController /** * If the table has to be moved to some other database */ - if (isset($_POST['submit_move']) || isset($_POST['submit_copy'])) { + if ($request->hasBodyParam('submit_move') || $request->hasBodyParam('submit_copy')) { $message = $this->operations->moveOrCopyTable($GLOBALS['db'], $GLOBALS['table']); if (! $this->response->isAjax()) { @@ -171,8 +173,10 @@ class OperationsController extends AbstractController $this->response->addJSON('message', $message); if ($message->isSuccess()) { - if (isset($_POST['submit_move'], $_POST['target_db'])) { - $GLOBALS['db'] = $_POST['target_db'];// Used in Header::getJsParams() + /** @var mixed $targetDbParam */ + $targetDbParam = $request->getParsedBodyParam('target_db'); + if ($request->hasBodyParam('submit_move') && is_string($targetDbParam)) { + $GLOBALS['db'] = $targetDbParam; // Used in Header::getJsParams() } $this->response->addJSON('db', $GLOBALS['db']); @@ -188,27 +192,31 @@ class OperationsController extends AbstractController /** * Updates table comment, type and options if required */ - if (isset($_POST['submitoptions'])) { + if ($request->hasBodyParam('submitoptions')) { $_message = ''; $GLOBALS['warning_messages'] = []; - if (isset($_POST['new_name'])) { + /** @var mixed $newName */ + $newName = $request->getParsedBodyParam('new_name'); + if (is_string($newName)) { // lower_case_table_names=1 `DB` becomes `db` if ($GLOBALS['lowerCaseNames']) { - $_POST['new_name'] = mb_strtolower($_POST['new_name']); + $newName = mb_strtolower($newName); } // Get original names before rename operation $oldTable = $pma_table->getName(); $oldDb = $pma_table->getDbName(); - if ($pma_table->rename($_POST['new_name'])) { - if (isset($_POST['adjust_privileges']) && ! empty($_POST['adjust_privileges'])) { + if ($pma_table->rename($newName)) { + if ($request->getParsedBodyParam('adjust_privileges')) { + /** @var mixed $dbParam */ + $dbParam = $request->getParsedBodyParam('db'); $this->operations->adjustPrivilegesRenameOrMoveTable( $oldDb, $oldTable, - $_POST['db'], - $_POST['new_name'] + is_string($dbParam) ? $dbParam : '', + $newName ); } @@ -226,11 +234,13 @@ class OperationsController extends AbstractController } } + /** @var mixed $newTableStorageEngine */ + $newTableStorageEngine = $request->getParsedBodyParam('new_tbl_storage_engine'); if ( - ! empty($_POST['new_tbl_storage_engine']) - && mb_strtoupper($_POST['new_tbl_storage_engine']) !== $GLOBALS['tbl_storage_engine'] + is_string($newTableStorageEngine) && $newTableStorageEngine !== '' + && mb_strtoupper($newTableStorageEngine) !== $GLOBALS['tbl_storage_engine'] ) { - $GLOBALS['new_tbl_storage_engine'] = mb_strtoupper($_POST['new_tbl_storage_engine']); + $GLOBALS['new_tbl_storage_engine'] = mb_strtoupper($newTableStorageEngine); if ($pma_table->isEngine('ARIA')) { $GLOBALS['create_options']['transactional'] = ($GLOBALS['create_options']['transactional'] ?? '') @@ -267,15 +277,20 @@ class OperationsController extends AbstractController $GLOBALS['warning_messages'] = $this->operations->getWarningMessagesArray(); } - if (! empty($_POST['tbl_collation']) && ! empty($_POST['change_all_collations'])) { + /** @var mixed $tableCollationParam */ + $tableCollationParam = $request->getParsedBodyParam('tbl_collation'); + if ( + is_string($tableCollationParam) && $tableCollationParam !== '' + && $request->getParsedBodyParam('change_all_collations') + ) { $this->operations->changeAllColumnsCollation( $GLOBALS['db'], $GLOBALS['table'], - $_POST['tbl_collation'] + $tableCollationParam ); } - if (isset($_POST['tbl_collation']) && empty($_POST['tbl_collation'])) { + if ($tableCollationParam !== null && (! is_string($tableCollationParam) || $tableCollationParam === '')) { if ($this->response->isAjax()) { $this->response->setRequestStatus(false); $this->response->addJSON( @@ -288,26 +303,38 @@ class OperationsController extends AbstractController } } + /** @var mixed $orderField */ + $orderField = $request->getParsedBodyParam('order_field'); + /** * Reordering the table has been requested by the user */ - if (isset($_POST['submitorderby']) && ! empty($_POST['order_field'])) { + if ($request->hasBodyParam('submitorderby') && is_string($orderField) && $orderField !== '') { + /** @var mixed $orderOrder */ + $orderOrder = $request->getParsedBodyParam('order_order'); $GLOBALS['sql_query'] = QueryGenerator::getQueryForReorderingTable( $GLOBALS['table'], - urldecode($_POST['order_field']), - $_POST['order_order'] ?? null + urldecode($orderField), + is_string($orderOrder) ? $orderOrder : '' ); $GLOBALS['result'] = $this->dbi->query($GLOBALS['sql_query']); } + /** @var mixed $partitionOperation */ + $partitionOperation = $request->getParsedBodyParam('partition_operation'); + /** * A partition operation has been requested by the user */ - if (isset($_POST['submit_partition']) && ! empty($_POST['partition_operation'])) { + if ( + $request->hasBodyParam('submit_partition') && is_string($partitionOperation) && $partitionOperation !== '' + ) { + /** @var mixed $partitionNames */ + $partitionNames = $request->getParsedBodyParam('partition_name'); $GLOBALS['sql_query'] = QueryGenerator::getQueryForPartitioningTable( $GLOBALS['table'], - $_POST['partition_operation'], - $_POST['partition_name'] + $partitionOperation, + is_array($partitionNames) ? $partitionNames : [] ); $GLOBALS['result'] = $this->dbi->query($GLOBALS['sql_query']); } diff --git a/libraries/classes/Controllers/Table/Structure/PrimaryController.php b/libraries/classes/Controllers/Table/Structure/PrimaryController.php index d218e1d94a..79777e0787 100644 --- a/libraries/classes/Controllers/Table/Structure/PrimaryController.php +++ b/libraries/classes/Controllers/Table/Structure/PrimaryController.php @@ -17,6 +17,7 @@ use PhpMyAdmin\Util; use function __; use function count; +use function is_array; final class PrimaryController extends AbstractController { @@ -43,26 +44,23 @@ final class PrimaryController extends AbstractController $GLOBALS['urlParams'] = $GLOBALS['urlParams'] ?? null; $GLOBALS['errorUrl'] = $GLOBALS['errorUrl'] ?? null; - $selected = $request->getParsedBodyParam('selected', []); - $selected_fld = $request->getParsedBodyParam('selected_fld', []); + /** @var string[]|null $selected */ + $selected = $request->getParsedBodyParam('selected_fld', $request->getParsedBodyParam('selected')); - if (empty($selected) && empty($selected_fld)) { + if (! is_array($selected) || $selected === []) { $this->response->setRequestStatus(false); $this->response->addJSON('message', __('No column selected.')); return; } - $primary = $this->getKeyForTablePrimary(); - if (empty($primary) && ! empty($selected_fld)) { - // no primary key, so we can safely create new - $mult_btn = __('Yes'); - $selected = $selected_fld; - } + $this->dbi->selectDb($GLOBALS['db']); + $hasPrimary = $this->hasPrimaryKey(); - $mult_btn = $_POST['mult_btn'] ?? $mult_btn ?? ''; + /** @var string|null $deletionConfirmed */ + $deletionConfirmed = $request->getParsedBodyParam('mult_btn', null); - if (! empty($selected_fld) && ! empty($primary)) { + if ($hasPrimary && $deletionConfirmed === null) { $this->checkParameters(['db', 'table']); $GLOBALS['urlParams'] = ['db' => $GLOBALS['db'], 'table' => $GLOBALS['table']]; @@ -74,15 +72,15 @@ final class PrimaryController extends AbstractController $this->render('table/structure/primary', [ 'db' => $GLOBALS['db'], 'table' => $GLOBALS['table'], - 'selected' => $selected_fld, + 'selected' => $selected, ]); return; } - if ($mult_btn === __('Yes')) { + if ($deletionConfirmed === __('Yes') || ! $hasPrimary) { $GLOBALS['sql_query'] = 'ALTER TABLE ' . Util::backquote($GLOBALS['table']); - if (! empty($primary)) { + if ($hasPrimary) { $GLOBALS['sql_query'] .= ' DROP PRIMARY KEY,'; } @@ -110,27 +108,16 @@ final class PrimaryController extends AbstractController ($this->structureController)($request); } - /** - * Gets table primary key - * - * @return string - */ - private function getKeyForTablePrimary() + private function hasPrimaryKey(): bool { - $this->dbi->selectDb($GLOBALS['db']); - $result = $this->dbi->query( - 'SHOW KEYS FROM ' . Util::backquote($GLOBALS['table']) . ';' - ); - $primary = ''; + $result = $this->dbi->query('SHOW KEYS FROM ' . Util::backquote($GLOBALS['table'])); + foreach ($result as $row) { - // Backups the list of primary keys - if ($row['Key_name'] !== 'PRIMARY') { - continue; + if ($row['Key_name'] === 'PRIMARY') { + return true; } - - $primary .= $row['Column_name'] . ', '; } - return $primary; + return false; } } diff --git a/libraries/classes/Controllers/Table/TrackingController.php b/libraries/classes/Controllers/Table/TrackingController.php index acf0502ed1..db5dbdc2ad 100644 --- a/libraries/classes/Controllers/Table/TrackingController.php +++ b/libraries/classes/Controllers/Table/TrackingController.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpMyAdmin\Controllers\Table; +use DateTimeImmutable; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\DbTableExists; use PhpMyAdmin\Http\ServerRequest; @@ -14,6 +15,8 @@ use PhpMyAdmin\Tracker; use PhpMyAdmin\Tracking; use PhpMyAdmin\Url; use PhpMyAdmin\Util; +use Throwable; +use Webmozart\Assert\Assert; use function __; use function array_map; @@ -23,7 +26,6 @@ use function htmlspecialchars; use function in_array; use function is_array; use function sprintf; -use function strtotime; final class TrackingController extends AbstractController { @@ -46,8 +48,6 @@ final class TrackingController extends AbstractController $GLOBALS['msg'] = $GLOBALS['msg'] ?? null; $GLOBALS['errorUrl'] = $GLOBALS['errorUrl'] ?? null; $GLOBALS['entries'] = $GLOBALS['entries'] ?? null; - $GLOBALS['filter_ts_from'] = $GLOBALS['filter_ts_from'] ?? null; - $GLOBALS['filter_ts_to'] = $GLOBALS['filter_ts_to'] ?? null; $GLOBALS['filter_users'] = $GLOBALS['filter_users'] ?? null; $this->addScriptFiles(['vendor/jquery/jquery.tablesorter.js', 'table/tracking.js']); @@ -86,8 +86,6 @@ final class TrackingController extends AbstractController $trackedData = []; $GLOBALS['entries'] = []; - $GLOBALS['filter_ts_from'] = null; - $GLOBALS['filter_ts_to'] = null; $GLOBALS['filter_users'] = []; $report = $request->hasBodyParam('report'); @@ -98,8 +96,8 @@ final class TrackingController extends AbstractController $logType = $this->validateLogTypeParam($request->getParsedBodyParam('log_type')); - $dateFrom = ''; - $dateTo = ''; + $dateFrom = null; + $dateTo = null; $users = ''; // Init vars for tracking report @@ -110,26 +108,28 @@ final class TrackingController extends AbstractController $versionParam ); - /** @var string $dateFrom */ - $dateFrom = $request->getParsedBodyParam('date_from', $trackedData['date_from']); - /** @var string $dateTo */ - $dateTo = $request->getParsedBodyParam('date_to', $trackedData['date_to']); + $dateFrom = $this->validateDateTimeParam( + $request->getParsedBodyParam('date_from', $trackedData['date_from']) + ); + $dateTo = $this->validateDateTimeParam($request->getParsedBodyParam('date_to', $trackedData['date_to'])); + /** @var string $users */ $users = $request->getParsedBodyParam('users', '*'); - $GLOBALS['filter_ts_from'] = strtotime($dateFrom); - $GLOBALS['filter_ts_to'] = strtotime($dateTo); $GLOBALS['filter_users'] = array_map('trim', explode(',', $users)); } + $dateFrom = $dateFrom ?? new DateTimeImmutable(); + $dateTo = $dateTo ?? new DateTimeImmutable(); + // Prepare export if ($reportExport !== null) { $GLOBALS['entries'] = $this->tracking->getEntries( $trackedData, - (int) $GLOBALS['filter_ts_from'], - (int) $GLOBALS['filter_ts_to'], $GLOBALS['filter_users'], - $logType + $logType, + $dateFrom, + $dateTo ); } @@ -239,8 +239,6 @@ final class TrackingController extends AbstractController $trackedData, $GLOBALS['urlParams'], $logType, - (int) $GLOBALS['filter_ts_to'], - (int) $GLOBALS['filter_ts_from'], $GLOBALS['filter_users'], $versionParam, $dateFrom, @@ -281,4 +279,18 @@ final class TrackingController extends AbstractController { return in_array($param, ['schema', 'data'], true) ? $param : 'schema_and_data'; } + + /** + * @param mixed $param + */ + private function validateDateTimeParam($param): DateTimeImmutable + { + try { + Assert::stringNotEmpty($param); + + return new DateTimeImmutable($param); + } catch (Throwable $exception) { + return new DateTimeImmutable(); + } + } } diff --git a/libraries/classes/Controllers/Table/TriggersController.php b/libraries/classes/Controllers/Table/TriggersController.php index ba6d60159d..67f3f7c5e5 100644 --- a/libraries/classes/Controllers/Table/TriggersController.php +++ b/libraries/classes/Controllers/Table/TriggersController.php @@ -44,7 +44,6 @@ class TriggersController extends AbstractController $GLOBALS['tables'] = $GLOBALS['tables'] ?? null; $GLOBALS['num_tables'] = $GLOBALS['num_tables'] ?? null; $GLOBALS['total_num_tables'] = $GLOBALS['total_num_tables'] ?? null; - $GLOBALS['sub_part'] = $GLOBALS['sub_part'] ?? null; $GLOBALS['tooltip_truename'] = $GLOBALS['tooltip_truename'] ?? null; $GLOBALS['tooltip_aliasname'] = $GLOBALS['tooltip_aliasname'] ?? null; $GLOBALS['pos'] = $GLOBALS['pos'] ?? null; @@ -81,12 +80,11 @@ class TriggersController extends AbstractController [ $GLOBALS['tables'], $GLOBALS['num_tables'], - $GLOBALS['total_num_tables'], - $GLOBALS['sub_part'],,, + $GLOBALS['total_num_tables'],,, $GLOBALS['tooltip_truename'], $GLOBALS['tooltip_aliasname'], $GLOBALS['pos'], - ] = Util::getDbInfo($GLOBALS['db'], $GLOBALS['sub_part'] ?? ''); + ] = Util::getDbInfo($request, $GLOBALS['db']); } } elseif (strlen($GLOBALS['db']) > 0) { $this->dbi->selectDb($GLOBALS['db']); diff --git a/libraries/classes/Index.php b/libraries/classes/Index.php index 94cb50b641..03f1b20d67 100644 --- a/libraries/classes/Index.php +++ b/libraries/classes/Index.php @@ -88,14 +88,14 @@ class Index * * @var int */ - private $keyBlockSize = null; + private $keyBlockSize = 0; /** * Parser option for the index * * @var string */ - private $parser = null; + private $parser = ''; /** * @param array $params parameters @@ -341,7 +341,7 @@ class Index } if (isset($params['Key_block_size'])) { - $this->keyBlockSize = $params['Key_block_size']; + $this->keyBlockSize = (int) $params['Key_block_size']; } if (! isset($params['Parser'])) { @@ -383,10 +383,8 @@ class Index /** * Return the key block size - * - * @return int */ - public function getKeyBlockSize() + public function getKeyBlockSize(): int { return $this->keyBlockSize; } diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php index 163f80d659..00fd96b6e1 100644 --- a/libraries/classes/Table.php +++ b/libraries/classes/Table.php @@ -205,24 +205,15 @@ class Table implements Stringable /** * Checks the storage engine used to create table * - * @param array|string $engine Checks the table engine against an + * @param string[]|string $engine Checks the table engine against an * array of engine strings or a single string, should be uppercase */ public function isEngine($engine): bool { + $engine = (array) $engine; $tableStorageEngine = $this->getStorageEngine(); - if (is_array($engine)) { - foreach ($engine as $e) { - if ($e == $tableStorageEngine) { - return true; - } - } - - return false; - } - - return $tableStorageEngine == $engine; + return in_array($tableStorageEngine, $engine, true); } /** @@ -362,9 +353,6 @@ class Table implements Stringable public function getStorageEngine(): string { $tableStorageEngine = $this->getStatusInfo('ENGINE', false, true); - if ($tableStorageEngine === false) { - return ''; - } return strtoupper((string) $tableStorageEngine); } @@ -2110,11 +2098,11 @@ class Table implements Stringable } $sqlQuery .= sprintf( - ' ADD %s ', + ' ADD %s', $index->getChoice() ); if ($index->getName()) { - $sqlQuery .= Util::backquote($index->getName()); + $sqlQuery .= ' ' . Util::backquote($index->getName()); } break; @@ -2130,18 +2118,15 @@ class Table implements Stringable $indexFields[$key] .= '(' . $column->getSubPart() . ')'; } - if (empty($indexFields)) { + if ($indexFields === []) { $error = Message::error(__('No index parts defined!')); } else { $sqlQuery .= ' (' . implode(', ', $indexFields) . ')'; } $keyBlockSizes = $index->getKeyBlockSize(); - if (! empty($keyBlockSizes)) { - $sqlQuery .= sprintf( - ' KEY_BLOCK_SIZE = %s', - $this->dbi->escapeString((string) $keyBlockSizes) - ); + if ($keyBlockSizes !== 0) { + $sqlQuery .= ' KEY_BLOCK_SIZE = ' . $keyBlockSizes; } // specifying index type is allowed only for primary, unique and index only @@ -2152,21 +2137,21 @@ class Table implements Stringable $index->getChoice() !== 'SPATIAL' && $index->getChoice() !== 'FULLTEXT' && in_array($type, Index::getIndexTypes()) - && ! $this->isEngine(['TOKUDB']) + && ! $this->isEngine('TOKUDB') ) { $sqlQuery .= ' USING ' . $type; } $parser = $index->getParser(); - if ($index->getChoice() === 'FULLTEXT' && ! empty($parser)) { - $sqlQuery .= ' WITH PARSER ' . $this->dbi->escapeString($parser); + if ($index->getChoice() === 'FULLTEXT' && $parser !== '') { + $sqlQuery .= ' WITH PARSER ' . $parser; } $comment = $index->getComment(); - if (! empty($comment)) { + if ($comment !== '') { $sqlQuery .= sprintf( - " COMMENT '%s'", - $this->dbi->escapeString($comment) + ' COMMENT %s', + $this->dbi->quoteString($comment) ); } diff --git a/libraries/classes/Tracking.php b/libraries/classes/Tracking.php index 1445d64b0b..3507cefa9f 100644 --- a/libraries/classes/Tracking.php +++ b/libraries/classes/Tracking.php @@ -7,6 +7,7 @@ declare(strict_types=1); namespace PhpMyAdmin; +use DateTimeImmutable; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Dbal\ResultInterface; use PhpMyAdmin\Html\Generator; @@ -63,18 +64,16 @@ class Tracking /** * Filters tracking entries * - * @param array $data the entries to filter - * @param int $filter_ts_from "from" date - * @param int $filter_ts_to "to" date - * @param array $filter_users users + * @param array $data the entries to filter + * @param array $filter_users users * * @return array filtered entries */ public function filter( array $data, - $filter_ts_from, - $filter_ts_to, - array $filter_users + array $filter_users, + DateTimeImmutable $dateFrom, + DateTimeImmutable $dateTo ): array { $tmp_entries = []; $id = 0; @@ -82,8 +81,8 @@ class Tracking $timestamp = strtotime($entry['date']); $filtered_user = in_array($entry['username'], $filter_users); if ( - $timestamp >= $filter_ts_from - && $timestamp <= $filter_ts_to + $timestamp >= $dateFrom->getTimestamp() + && $timestamp <= $dateTo->getTimestamp() && (in_array('*', $filter_users) || $filtered_user) ) { $tmp_entries[] = [ @@ -209,11 +208,9 @@ class Tracking /** * Function to get html for tracking report and tracking report export * - * @param array $data data - * @param array $url_params url params - * @param int $filter_ts_to filter time stamp from - * @param int $filter_ts_from filter time stamp tp - * @param array $filter_users filter users + * @param array $data data + * @param array $url_params url params + * @param array $filter_users filter users * @psalm-param 'schema'|'data'|'schema_and_data' $logType * * @return string @@ -222,12 +219,10 @@ class Tracking array $data, array $url_params, string $logType, - $filter_ts_to, - $filter_ts_from, array $filter_users, string $version, - string $dateFrom, - string $dateTo, + DateTimeImmutable $dateFrom, + DateTimeImmutable $dateTo, string $users ) { $html = '<h3>' . __('Tracking report') @@ -268,8 +263,6 @@ class Tracking $data, $url_params, $logType, - $filter_ts_to, - $filter_ts_from, $filter_users, $str1, $str2, @@ -277,7 +270,9 @@ class Tracking $str4, $str5, $drop_image_or_text, - $version + $version, + $dateFrom, + $dateTo ); $html .= $this->getHtmlForTrackingReportExportForm2( @@ -308,8 +303,8 @@ class Tracking */ public function getHtmlForElementsOfTrackingReport( string $logType, - string $dateFrom, - string $dateTo, + DateTimeImmutable $dateFrom, + DateTimeImmutable $dateTo, string $users ): array { $str1 = '<select name="log_type">' @@ -324,9 +319,9 @@ class Tracking . __('Structure and data') . '</option>' . '</select>'; $str2 = '<input type="text" name="date_from" value="' - . htmlspecialchars($dateFrom) . '" size="19">'; + . htmlspecialchars($dateFrom->format('Y-m-d H:i:s')) . '" size="19">'; $str3 = '<input type="text" name="date_to" value="' - . htmlspecialchars($dateTo) . '" size="19">'; + . htmlspecialchars($dateTo->format('Y-m-d H:i:s')) . '" size="19">'; $str4 = '<input type="text" name="users" value="' . htmlspecialchars($users) . '">'; $str5 = '<input type="hidden" name="list_report" value="1">' @@ -346,8 +341,6 @@ class Tracking * * @param array $data data * @param array $url_params url params - * @param int $filter_ts_to filter time stamp from - * @param int $filter_ts_from filter time stamp tp * @param array $filter_users filter users * @param string $str1 HTML for log_type select * @param string $str2 HTML for "from date" @@ -363,8 +356,6 @@ class Tracking array $data, array $url_params, string $logType, - $filter_ts_to, - $filter_ts_from, array $filter_users, $str1, $str2, @@ -372,7 +363,9 @@ class Tracking $str4, $str5, $drop_image_or_text, - string $version + string $version, + DateTimeImmutable $dateFrom, + DateTimeImmutable $dateTo ) { $ddlog_count = 0; @@ -395,11 +388,11 @@ class Tracking [$temp, $ddlog_count] = $this->getHtmlForDataDefinitionStatements( $data, $filter_users, - $filter_ts_from, - $filter_ts_to, $url_params, $drop_image_or_text, - $version + $version, + $dateFrom, + $dateTo ); $html .= $temp; unset($temp); @@ -410,12 +403,12 @@ class Tracking $html .= $this->getHtmlForDataManipulationStatements( $data, $filter_users, - $filter_ts_from, - $filter_ts_to, $url_params, $ddlog_count, $drop_image_or_text, - $version + $version, + $dateFrom, + $dateTo ); } @@ -446,8 +439,8 @@ class Tracking $str5, string $logType, string $version, - string $dateFrom, - string $dateTo, + DateTimeImmutable $dateFrom, + DateTimeImmutable $dateTo, string $users ) { $html = '<form method="post" action="' . Url::getFromRoute('/table/tracking') . '">'; @@ -471,8 +464,8 @@ class Tracking 'report' => 'true', 'version' => $version, 'log_type' => $logType, - 'date_from' => $dateFrom, - 'date_to' => $dateTo, + 'date_from' => $dateFrom->format('Y-m-d H:i:s'), + 'date_to' => $dateTo->format('Y-m-d H:i:s'), 'users' => $users, 'report_export' => 'true', ]); @@ -501,8 +494,6 @@ class Tracking * * @param array $data data * @param array $filter_users filter users - * @param int $filter_ts_from filter time staml from - * @param int $filter_ts_to filter time stamp to * @param array $url_params url parameters * @param int $ddlog_count data definition log count * @param string $drop_image_or_text drop image or text @@ -512,26 +503,26 @@ class Tracking public function getHtmlForDataManipulationStatements( array $data, array $filter_users, - $filter_ts_from, - $filter_ts_to, array $url_params, $ddlog_count, $drop_image_or_text, - string $version + string $version, + DateTimeImmutable $dateFrom, + DateTimeImmutable $dateTo ) { // no need for the second returned parameter [$html] = $this->getHtmlForDataStatements( $data, $filter_users, - $filter_ts_from, - $filter_ts_to, $url_params, $drop_image_or_text, 'dmlog', __('Data manipulation statement'), $ddlog_count, 'dml_versions', - $version + $version, + $dateFrom, + $dateTo ); return $html; @@ -542,8 +533,6 @@ class Tracking * * @param array $data data * @param array $filter_users filter users - * @param int $filter_ts_from filter time stamp from - * @param int $filter_ts_to filter time stamp to * @param array $url_params url parameters * @param string $drop_image_or_text drop image or text * @@ -552,24 +541,24 @@ class Tracking public function getHtmlForDataDefinitionStatements( array $data, array $filter_users, - $filter_ts_from, - $filter_ts_to, array $url_params, $drop_image_or_text, - string $version + string $version, + DateTimeImmutable $dateFrom, + DateTimeImmutable $dateTo ) { [$html, $line_number] = $this->getHtmlForDataStatements( $data, $filter_users, - $filter_ts_from, - $filter_ts_to, $url_params, $drop_image_or_text, 'ddlog', __('Data definition statement'), 1, 'ddl_versions', - $version + $version, + $dateFrom, + $dateTo ); return [ @@ -583,8 +572,6 @@ class Tracking * * @param array $data data * @param array $filterUsers filter users - * @param int $filterTsFrom filter time stamp from - * @param int $filterTsTo filter time stamp to * @param array $urlParams url parameters * @param string $dropImageOrText drop image or text * @param string $whichLog dmlog|ddlog @@ -597,23 +584,23 @@ class Tracking private function getHtmlForDataStatements( array $data, array $filterUsers, - $filterTsFrom, - $filterTsTo, array $urlParams, $dropImageOrText, $whichLog, $headerMessage, $lineNumber, $tableId, - string $version + string $version, + DateTimeImmutable $dateFrom, + DateTimeImmutable $dateTo ) { $offset = $lineNumber; $entries = []; foreach ($data[$whichLog] as $entry) { $timestamp = strtotime($entry['date']); if ( - $timestamp >= $filterTsFrom - && $timestamp <= $filterTsTo + $timestamp >= $dateFrom->getTimestamp() + && $timestamp <= $dateTo->getTimestamp() && (in_array('*', $filterUsers) || in_array($entry['username'], $filterUsers)) ) { @@ -1070,27 +1057,25 @@ class Tracking /** * Function to get the entries * - * @param array $data data - * @param int $filter_ts_from filter time stamp from - * @param int $filter_ts_to filter time stamp to - * @param array $filter_users filter users + * @param array $data data + * @param array $filter_users filter users * @phpstan-param 'schema'|'data'|'schema_and_data' $logType * * @return array */ - public function getEntries(array $data, $filter_ts_from, $filter_ts_to, array $filter_users, string $logType) - { + public function getEntries( + array $data, + array $filter_users, + string $logType, + DateTimeImmutable $dateFrom, + DateTimeImmutable $dateTo + ) { $entries = []; // Filtering data definition statements if ($logType === 'schema' || $logType === 'schema_and_data') { $entries = array_merge( $entries, - $this->filter( - $data['ddlog'], - $filter_ts_from, - $filter_ts_to, - $filter_users - ) + $this->filter($data['ddlog'], $filter_users, $dateFrom, $dateTo) ); } @@ -1098,12 +1083,7 @@ class Tracking if ($logType === 'data' || $logType === 'schema_and_data') { $entries = array_merge( $entries, - $this->filter( - $data['dmlog'], - $filter_ts_from, - $filter_ts_to, - $filter_users - ) + $this->filter($data['dmlog'], $filter_users, $dateFrom, $dateTo) ); } diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index 41ce36f251..cd2f9060c0 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -6,6 +6,7 @@ namespace PhpMyAdmin; use PhpMyAdmin\Dbal\ResultInterface; use PhpMyAdmin\Html\Generator; +use PhpMyAdmin\Http\ServerRequest; use PhpMyAdmin\Query\Compatibility; use PhpMyAdmin\Query\Utilities; use PhpMyAdmin\SqlParser\Components\Expression; @@ -43,6 +44,7 @@ use function implode; use function in_array; use function ini_get; use function is_array; +use function is_numeric; use function is_object; use function is_scalar; use function is_string; @@ -2068,15 +2070,11 @@ class Util } /** - * Gets the list of tables in the current db and information about these - * tables if possible - * - * @param string $db database name - * @param string $subPart part of script name + * Gets the list of tables in the current db and information about these tables if possible. * * @return array */ - public static function getDbInfo($db, string $subPart) + public static function getDbInfo(ServerRequest $request, string $db, bool $isResultLimited = true): array { /** * limits for table list @@ -2086,8 +2084,10 @@ class Util $_SESSION['tmpval']['table_limit_offset_db'] = $db; } - if (isset($_REQUEST['pos'])) { - $_SESSION['tmpval']['table_limit_offset'] = (int) $_REQUEST['pos']; + /** @var mixed $posParam */ + $posParam = $request->getParam('pos'); + if (is_numeric($posParam)) { + $_SESSION['tmpval']['table_limit_offset'] = (int) $posParam; } $pos = $_SESSION['tmpval']['table_limit_offset']; @@ -2132,7 +2132,9 @@ class Util $sort = 'Name'; $sortOrder = 'ASC'; - if (isset($_REQUEST['sort'])) { + /** @var mixed $sortParam */ + $sortParam = $request->getParam('sort'); + if (is_string($sortParam)) { $sortableNameMappings = [ 'table' => 'Name', 'records' => 'Rows', @@ -2147,9 +2149,9 @@ class Util ]; // Make sure the sort type is implemented - if (isset($sortableNameMappings[$_REQUEST['sort']])) { - $sort = $sortableNameMappings[$_REQUEST['sort']]; - if ($_REQUEST['sort_order'] === 'DESC') { + if (isset($sortableNameMappings[$sortParam])) { + $sort = $sortableNameMappings[$sortParam]; + if ($request->getParam('sort_order') === 'DESC') { $sortOrder = 'DESC'; } } @@ -2161,15 +2163,22 @@ class Util $limitCount = false; $groupTable = []; - if (! empty($_REQUEST['tbl_group']) || ! empty($_REQUEST['tbl_type'])) { - if (! empty($_REQUEST['tbl_type'])) { + /** @var mixed $tableGroupParam */ + $tableGroupParam = $request->getParam('tbl_group'); + /** @var mixed $tableTypeParam */ + $tableTypeParam = $request->getParam('tbl_type'); + if ( + is_string($tableGroupParam) && $tableGroupParam !== '' + || is_string($tableTypeParam) && $tableTypeParam !== '' + ) { + if (is_string($tableTypeParam) && $tableTypeParam !== '') { // only tables for selected type - $tableType = $_REQUEST['tbl_type']; + $tableType = $tableTypeParam; } - if (! empty($_REQUEST['tbl_group'])) { + if (is_string($tableGroupParam) && $tableGroupParam !== '') { // only tables for selected group - $tableGroup = $_REQUEST['tbl_group']; + $tableGroup = $tableGroupParam; // include the table with the exact name of the group if such // exists $groupTable = $GLOBALS['dbi']->getTablesFull( @@ -2191,7 +2200,7 @@ class Util // (needed for proper working of the MaxTableList feature) $tables = $GLOBALS['dbi']->getTables($db); $totalNumTables = count($tables); - if ($subPart !== '_export') { + if ($isResultLimited) { // fetch the details for a possible limited subset $limitOffset = $pos; $limitCount = true; @@ -2217,19 +2226,10 @@ class Util $totalNumTables = $numTables; } - /** - * If coming from a Show MySQL link on the home page, - * put something in $sub_part - */ - if ($subPart === '') { - $subPart = '_structure'; - } - return [ $tables, $numTables, $totalNumTables, - $subPart, $isShowStats, $isSystemSchema, $tooltipTrueName, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 38ba64c2fa..3b21186df8 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1396,6 +1396,21 @@ parameters: path: libraries/classes/Controllers/SchemaExportController.php - + message: "#^Cannot cast mixed to int\\.$#" + count: 1 + path: libraries/classes/Controllers/Server/BinlogController.php + + - + message: "#^Parameter \\#1 \\$key of function array_key_exists expects int\\|string, mixed given\\.$#" + count: 1 + path: libraries/classes/Controllers/Server/BinlogController.php + + - + message: "#^Parameter \\#1 \\$log of method PhpMyAdmin\\\\Controllers\\\\Server\\\\BinlogController\\:\\:getSqlQuery\\(\\) expects string, mixed given\\.$#" + count: 1 + path: libraries/classes/Controllers/Server/BinlogController.php + + - message: "#^Property PhpMyAdmin\\\\Controllers\\\\Server\\\\BinlogController\\:\\:\\$binaryLogs type has no value type specified in iterable type array\\.$#" count: 1 path: libraries/classes/Controllers/Server/BinlogController.php @@ -1733,21 +1748,6 @@ parameters: - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" count: 1 - path: libraries/classes/Controllers/Table/Structure/PrimaryController.php - - - - message: "#^Parameter \\#1 \\$identifier of static method PhpMyAdmin\\\\Util\\:\\:backquote\\(\\) expects string\\|Stringable\\|null, mixed given\\.$#" - count: 1 - path: libraries/classes/Controllers/Table/Structure/PrimaryController.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 1 - path: libraries/classes/Controllers/Table/Structure/PrimaryController.php - - - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" - count: 1 path: libraries/classes/Controllers/Table/Structure/ReservedWordCheckController.php - @@ -8081,11 +8081,6 @@ parameters: path: libraries/classes/Table.php - - message: "#^Method PhpMyAdmin\\\\Table\\:\\:isEngine\\(\\) has parameter \\$engine with no value type specified in iterable type array\\.$#" - count: 1 - path: libraries/classes/Table.php - - - message: "#^Method PhpMyAdmin\\\\Table\\:\\:updateForeignKeys\\(\\) has parameter \\$destinationForeignColumn with no value type specified in iterable type array\\.$#" count: 1 path: libraries/classes/Table.php @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin-docs 4.0.0-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2022-11-06 00:22+0000\n" -"PO-Revision-Date: 2022-11-06 09:12+0000\n" -"Last-Translator: Olivier Humbert <trebmuh@tuxfamily.org>\n" +"PO-Revision-Date: 2022-11-07 12:02+0000\n" +"Last-Translator: William Desportes <williamdes@wdes.fr>\n" "Language-Team: French <https://hosted.weblate.org/projects/phpmyadmin/master/" "fr/>\n" "Language: fr\n" @@ -5512,7 +5512,7 @@ msgstr "" #: libraries/classes/Controllers/Import/ImportController.php:249 msgid "Incorrect format parameter" -msgstr "Paramètre de format incorrect" +msgstr "Paramètre \"format\" incorrect" #: libraries/classes/Controllers/Import/ImportController.php:379 #: libraries/classes/Controllers/Import/ImportController.php:622 @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 5.3.0-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2022-11-06 00:22+0000\n" -"PO-Revision-Date: 2022-11-06 09:12+0000\n" +"PO-Revision-Date: 2022-11-09 01:12+0000\n" "Last-Translator: Kristijan Fremen Velkovski <me@krisfremen.com>\n" "Language-Team: Macedonian <https://hosted.weblate.org/projects/phpmyadmin/" "master/mk/>\n" @@ -1063,9 +1063,8 @@ msgid "Query cache fragmentation" msgstr "Вид на упит" #: libraries/classes/Advisory/Rules.php:819 -#, fuzzy msgid "The query cache is considerably fragmented." -msgstr "Серверот не одговара" +msgstr "Кешот за барања е значително фрагментиран." #: libraries/classes/Advisory/Rules.php:821 msgid "" @@ -5323,9 +5322,8 @@ msgid "Do you really want to remove partitioning?" msgstr "Дали навистина сакате да ги отстраните партициите?" #: libraries/classes/Controllers/JavaScriptMessagesController.php:90 -#, fuzzy msgid "Do you really want to reset the replica (RESET REPLICA)?" -msgstr "Дали навистина сакате да " +msgstr "Дали навистина сакате да ја ресетирате репликата (RESET REPLICA)?" #: libraries/classes/Controllers/JavaScriptMessagesController.php:92 msgid "" @@ -5408,9 +5406,8 @@ msgstr "Ажурирање на следниот запис" #. l10n: Rename a table Index #: libraries/classes/Controllers/JavaScriptMessagesController.php:126 -#, fuzzy msgid "Rename index" -msgstr "Промени го името на табелата во " +msgstr "Преименувај го индексот" #: libraries/classes/Controllers/JavaScriptMessagesController.php:127 #: templates/table/index_form.twig:237 @@ -6501,9 +6498,8 @@ msgstr "Примарниот клуч %s е додаден." #: libraries/classes/Controllers/JavaScriptMessagesController.php:428 #: libraries/classes/Normalization.php:281 -#, fuzzy msgid "Taking you to next step…" -msgstr "Промени" +msgstr "Кон следниот чекор…" #: libraries/classes/Controllers/JavaScriptMessagesController.php:429 #, php-format @@ -7130,9 +7126,8 @@ msgid "Execute this query again?" msgstr "Прикажи го повторно овој упит" #: libraries/classes/Controllers/JavaScriptMessagesController.php:661 -#, fuzzy msgid "Do you really want to delete this bookmark?" -msgstr "Дали навистина сакате да " +msgstr "Дали навистина сакате да ја избришете ознаката?" #: libraries/classes/Controllers/JavaScriptMessagesController.php:662 msgid "Some error occurred while getting SQL debug info." @@ -7695,9 +7690,8 @@ msgstr "" #: libraries/classes/Controllers/Normalization/GetColumnsController.php:29 #: libraries/classes/Normalization.php:244 -#, fuzzy msgid "Select one…" -msgstr "Додади/избриши колона" +msgstr "Изберете еден…" #: libraries/classes/Controllers/Normalization/GetColumnsController.php:30 #: libraries/classes/Normalization.php:245 @@ -11549,9 +11543,8 @@ msgid "" msgstr "" #: libraries/classes/Plugins/Import/ImportLdi.php:62 -#, fuzzy msgid "Column names: " -msgstr "Имиња на колони" +msgstr "Имиња на колони: " #: libraries/classes/Plugins/Import/ImportLdi.php:116 msgid "This plugin does not support compressed imports!" @@ -14394,9 +14387,8 @@ msgstr "во упитот" #: templates/database/designer/main.twig:495 #: templates/database/designer/main.twig:711 -#, fuzzy msgid "Rename to" -msgstr "Промени го името на табелата во " +msgstr "Преименувајте во" #: templates/database/designer/main.twig:501 #: templates/database/designer/main.twig:719 @@ -15188,9 +15180,8 @@ msgstr "Додади AUTO_INCREMENT вредност" #: templates/table/delete/confirm.twig:12 #: templates/table/structure/drop_confirm.twig:7 #: templates/table/structure/primary.twig:3 -#, fuzzy msgid "Do you really want to execute the following query?" -msgstr "Дали навистина сакате да " +msgstr "Дали навистина сакате да егзекутурате следното барање?" #: templates/database/structure/favorite_anchor.twig:4 #: templates/recent_favorite_table_favorite.twig:6 @@ -16110,9 +16101,8 @@ msgstr "Операции" #: templates/indexes.twig:39 #: templates/table/structure/display_structure.twig:489 -#, fuzzy msgid "Rename" -msgstr "Промени го името на табелата во " +msgstr "Преименувај" #: templates/indexes.twig:45 #: templates/table/structure/display_structure.twig:495 @@ -16478,9 +16468,8 @@ msgid "phpMyAdmin configuration storage" msgstr "phpMyAdmin документација" #: templates/relation/check_relations.twig:9 -#, fuzzy msgid "Configuration of pmadb…" -msgstr "Измените се сочувани" +msgstr "Конфигурација на pmadb…" #: templates/relation/check_relations.twig:10 #: templates/relation/check_relations.twig:56 @@ -16658,9 +16647,8 @@ msgid "Managing central list of columns:" msgstr "" #: templates/relation/check_relations.twig:483 -#, fuzzy msgid "Remembering designer settings:" -msgstr "Промени го името на табелата во " +msgstr "Запомни подесувања за дизајн:" #: templates/relation/check_relations.twig:508 #, fuzzy @@ -18597,9 +18585,8 @@ msgid "Check referential integrity" msgstr "Провери го референцијалниот интегритет:" #: templates/table/operations/view.twig:12 -#, fuzzy msgid "Rename view to" -msgstr "Промени го името на табелата во " +msgstr "Преименувај го погледот во" #: templates/table/operations/view.twig:37 #, fuzzy @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 5.3.0-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2022-11-06 00:22+0000\n" -"PO-Revision-Date: 2022-10-18 19:02+0000\n" +"PO-Revision-Date: 2022-11-07 12:02+0000\n" "Last-Translator: Domen <mitenem@outlook.com>\n" "Language-Team: Slovenian <https://hosted.weblate.org/projects/phpmyadmin/" "master/sl/>\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" "%100==4 ? 2 : 3;\n" -"X-Generator: Weblate 4.15-dev\n" +"X-Generator: Weblate 4.14.2\n" #: libraries/classes/Advisory/Advisor.php:240 #, php-format @@ -5402,10 +5402,8 @@ msgstr "" "%sdokumentaciji%s ogledate načine, kako obiti omejitev." #: libraries/classes/Controllers/Import/ImportController.php:249 -#, fuzzy -#| msgid "Incorrect form specified!" msgid "Incorrect format parameter" -msgstr "Določena je neveljavna oblika!" +msgstr "Neveljaven parameter oblike" #: libraries/classes/Controllers/Import/ImportController.php:379 #: libraries/classes/Controllers/Import/ImportController.php:622 @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 5.3.0-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2022-11-06 00:22+0000\n" -"PO-Revision-Date: 2022-10-29 17:26+0000\n" -"Last-Translator: JonathanExam <644245001@mcru.ac.th>\n" +"PO-Revision-Date: 2022-11-07 12:02+0000\n" +"Last-Translator: AefghThreenine <aefgh39622@gmail.com>\n" "Language-Team: Thai <https://hosted.weblate.org/projects/phpmyadmin/master/" "th/>\n" "Language: th\n" @@ -13,7 +13,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.14.2-dev\n" +"X-Generator: Weblate 4.14.2\n" #: libraries/classes/Advisory/Advisor.php:240 #, php-format @@ -4495,7 +4495,7 @@ msgstr "อื่นๆ" #: libraries/classes/Config/Descriptions.php:987 msgid "Server connection collation" -msgstr "ตรวจทานการเชื่อมต่อเซิร์ฟเวอร์" +msgstr "การเรียงลำดับสำหรับการเชื่อมต่อเซิร์ฟเวอร์" #: libraries/classes/Config/FormDisplay.php:601 #, php-format @@ -4505,10 +4505,8 @@ msgstr "ข้อมูลที่หายไปสำหรับ %s" #: libraries/classes/Config/FormDisplay.php:642 #: libraries/classes/Config/Validator.php:590 #: templates/config/form_display/display.twig:67 -#, fuzzy -#| msgid "Incorrect value" msgid "Incorrect value!" -msgstr "ค่าไม่ถูกต้อง" +msgstr "ค่าไม่ถูกต้อง!" #: libraries/classes/Config/FormDisplay.php:793 #: libraries/classes/Config/FormDisplay.php:802 @@ -4524,12 +4522,12 @@ msgstr "\"%s\" ต้องใช้ส่วนขยาย %s" #: libraries/classes/Config/FormDisplay.php:835 #, php-format msgid "Compressed import will not work due to missing function %s." -msgstr "" +msgstr "ไม่สามารถใช้การนำเข้าแบบบีบอัดได้เนื่องจากขาดฟังก์ชัน %s" #: libraries/classes/Config/FormDisplay.php:844 #, php-format msgid "Compressed export will not work due to missing function %s." -msgstr "" +msgstr "ไม่สามารถใช้การส่งออกแบบบีบอัดได้เนื่องจากขาดฟังก์ชัน %s" #: libraries/classes/Config/FormDisplay.php:863 #, php-format @@ -4550,7 +4548,7 @@ msgstr "การรับรองความถูกต้องของก #: libraries/classes/Config/Forms/User/ExportForm.php:25 msgid "Quick" -msgstr "" +msgstr "รวดเร็ว" #: libraries/classes/Config/Forms/User/ExportForm.php:29 msgid "Custom" @@ -9459,21 +9457,19 @@ msgid "May be approximate. See [doc@faq3-11]FAQ 3.11[/doc]." msgstr "มีข้อผิดพลาดระหว่างการอัพโหลด กรุณาดู [doc@faq1-11]FAQ 1.11[/doc]" #: libraries/classes/Display/Results.php:3763 -#, fuzzy, php-format -#| msgid "Showing rows" +#, php-format msgid "Showing rows %1s - %2s" -msgstr "แสดงแถว" +msgstr "กำลังแสดงแถวที่ %1s - %2s" #: libraries/classes/Display/Results.php:3777 #, php-format msgid "%1$d total, %2$d in query" -msgstr "" +msgstr "ทั้งหมด %1$d, %2$d ในคำค้น" #: libraries/classes/Display/Results.php:3782 -#, fuzzy, php-format -#| msgid "total" +#, php-format msgid "%d total" -msgstr "ทั้งหมด" +msgstr "ทั้งหมด %d" #: libraries/classes/Display/Results.php:3795 libraries/classes/Sql.php:942 #, fuzzy, php-format @@ -9975,11 +9971,9 @@ msgid "Profiling" msgstr "การทำแฟ้มประวัติ" #: libraries/classes/Html/Generator.php:745 -#, fuzzy -#| msgid "Add new field" msgctxt "Inline edit query" msgid "Edit inline" -msgstr "เพิ่มฟิลด์ใหม่" +msgstr "แก้ไขแบบอินไลน์" #: libraries/classes/Html/Generator.php:867 #, fuzzy @@ -12341,10 +12335,8 @@ msgid "Missing information to load the search." msgstr "" #: libraries/classes/SavedSearches.php:379 -#, fuzzy -#| msgid "Error while moving uploaded file." msgid "Error while loading the search." -msgstr "ข้อผิดพลาดขณะเคลื่อนย้ายไฟล์อัพโหลด" +msgstr "ข้อผิดพลาดขณะโหลดการค้นหา" #: libraries/classes/Server/Plugins.php:66 #: libraries/classes/Server/Privileges.php:795 @@ -13766,10 +13758,8 @@ msgstr "ชื่อตาราง" #: templates/console/display.twig:124 #: templates/database/central_columns/main.twig:196 templates/export.twig:285 #: templates/export.twig:301 templates/export.twig:317 -#, fuzzy -#| msgid "And" msgid "Add" -msgstr "และ" +msgstr "เพิ่ม" #: templates/columns_definitions/column_definitions_form.twig:39 #, fuzzy @@ -13778,10 +13768,8 @@ msgid "column(s)" msgstr "คอลัมน์" #: templates/columns_definitions/column_definitions_form.twig:73 -#, fuzzy -#| msgid "Collation" msgid "Collation:" -msgstr "การเรียงลำดับ" +msgstr "การเรียงลำดับ:" #: templates/columns_definitions/column_definitions_form.twig:76 msgid "Storage Engine:" @@ -14335,10 +14323,8 @@ msgstr "ตัวกรอง" #: templates/database/central_columns/main.twig:167 #: templates/display/results/table.twig:139 -#, fuzzy -#| msgid "Search in database" msgid "Search this table" -msgstr "ค้นหาในฐานข้อมูล" +msgstr "ค้นหาในตารางนี้" #: templates/database/central_columns/main.twig:178 #: templates/table/structure/display_structure.twig:418 @@ -15647,8 +15633,6 @@ msgid "Trigger name" msgstr "ชื่อผู้ใช้" #: templates/database/triggers/editor_form.twig:37 -#, fuzzy -#| msgid "Time" msgctxt "Trigger action time" msgid "Time" msgstr "เวลา" @@ -15724,10 +15708,8 @@ msgstr "เพิ่ม/ลบ คอลัมน์ (ฟิลด์)" #: templates/display/results/table.twig:124 templates/export.twig:149 #: templates/table/start_and_number_of_rows_fieldset.twig:9 -#, fuzzy -#| msgid "Number of rows per page" msgid "Number of rows:" -msgstr "ระเบียนต่อหน้า" +msgstr "จำนวนแถว:" #: templates/display/results/table.twig:127 msgid "All" @@ -19121,10 +19103,8 @@ msgid "Table %s has been flushed." msgstr "ล้างตาราง %s เรียบร้อยแล้ว" #: templates/table/operations/index.twig:376 -#, fuzzy -#| msgid "Flush the table (\"FLUSH\")" msgid "Flush the table (FLUSH)" -msgstr "ล้างตาราง (flush)" +msgstr "ล้างตาราง (FLUSH)" #: templates/table/operations/index.twig:413 msgid "Empty the table (TRUNCATE)" @@ -19137,9 +19117,8 @@ msgid "Empty the table (DELETE FROM)" msgstr "ลบข้อมูลตาราง (TRUNCATE)" #: templates/table/operations/index.twig:452 -#, fuzzy msgid "Delete the table (DROP)" -msgstr "ไม่มีฐานข้อมูล" +msgstr "ลบตาราง (DROP)" #: templates/table/operations/index.twig:474 #, fuzzy @@ -19158,14 +19137,12 @@ msgid "Check referential integrity" msgstr "ตรวจสอบความสมบูรณ์ของการอ้างถึง:" #: templates/table/operations/view.twig:12 -#, fuzzy msgid "Rename view to" -msgstr "เปลี่ยนชื่อตารางเป็น" +msgstr "เปลี่ยนชื่อวิวเป็น" #: templates/table/operations/view.twig:37 -#, fuzzy msgid "Delete the view (DROP)" -msgstr "ไม่มีฐานข้อมูล" +msgstr "ลบวิว (DROP)" #: templates/table/page_with_secondary_tabs.twig:11 #, fuzzy diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 82109fffdd..832def3006 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<files psalm-version="4.29.0@7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3"> +<files psalm-version="4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69"> <file src="libraries/classes/Advisory/Advisor.php"> <MixedArgument occurrences="8"> <code>$matches[1]</code> @@ -1083,8 +1083,7 @@ <code>$_POST['selected_page']</code> <code>$_POST['selected_page']</code> </InvalidScalarArgument> - <MixedArgument occurrences="5"> - <code>$GLOBALS['sub_part'] ?? ''</code> + <MixedArgument occurrences="4"> <code>$GLOBALS['success']</code> <code>$html</code> <code>$position['dbName']</code> @@ -1096,7 +1095,7 @@ <code>$position['tableName']</code> <code>$position['tableName']</code> </MixedArrayAccess> - <MixedAssignment occurrences="22"> + <MixedAssignment occurrences="21"> <code>$GLOBALS['classes_side_menu']</code> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['fullTableNames']</code> @@ -1108,7 +1107,6 @@ <code>$GLOBALS['script_display_field']</code> <code>$GLOBALS['script_tables']</code> <code>$GLOBALS['selected_page']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['success']</code> <code>$GLOBALS['tab_column']</code> <code>$GLOBALS['tab_pos']</code> @@ -1201,15 +1199,11 @@ </RiskyCast> </file> <file src="libraries/classes/Controllers/Database/EventsController.php"> - <MixedArgument occurrences="1"> - <code>$GLOBALS['sub_part'] ?? ''</code> - </MixedArgument> - <MixedAssignment occurrences="9"> + <MixedAssignment occurrences="8"> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['errors']</code> <code>$GLOBALS['num_tables']</code> <code>$GLOBALS['pos']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['tooltip_aliasname']</code> <code>$GLOBALS['tooltip_truename']</code> @@ -1233,12 +1227,11 @@ <code>$each_table['Name']</code> <code>$each_table['Name']</code> </MixedArrayAccess> - <MixedAssignment occurrences="12"> + <MixedAssignment occurrences="11"> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['num_tables']</code> <code>$GLOBALS['pos']</code> <code>$GLOBALS['single_table']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['table_select']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['tooltip_aliasname']</code> @@ -1255,9 +1248,6 @@ </PossiblyNullIterator> </file> <file src="libraries/classes/Controllers/Database/ImportController.php"> - <MixedArgument occurrences="1"> - <code>$GLOBALS['sub_part'] ?? ''</code> - </MixedArgument> <MixedArrayAccess occurrences="2"> <code>$_SESSION[$GLOBALS['SESSION_KEY']]['handler']</code> <code>$_SESSION[$GLOBALS['SESSION_KEY']]['handler']</code> @@ -1266,11 +1256,10 @@ <code>$_SESSION[$GLOBALS['SESSION_KEY']]</code> <code>$_SESSION[$GLOBALS['SESSION_KEY']]</code> </MixedArrayOffset> - <MixedAssignment occurrences="9"> + <MixedAssignment occurrences="8"> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['num_tables']</code> <code>$GLOBALS['pos']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['tooltip_aliasname']</code> <code>$GLOBALS['tooltip_truename']</code> @@ -1318,7 +1307,7 @@ <code>$GLOBALS['cfg']['AllowUserDropDatabase']</code> <code>$GLOBALS['cfg']['PmaNoRelation_DisableWarning']</code> </InvalidArrayOffset> - <MixedAssignment occurrences="18"> + <MixedAssignment occurrences="17"> <code>$GLOBALS['db_collation']</code> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['export_sql_plugin']</code> @@ -1330,7 +1319,6 @@ <code>$GLOBALS['reload']</code> <code>$GLOBALS['single_table']</code> <code>$GLOBALS['sqlConstratints']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['tables_full']</code> <code>$GLOBALS['tooltip_aliasname']</code> @@ -1367,14 +1355,13 @@ <InvalidArgument occurrences="1"> <code>$_POST['searchId']</code> </InvalidArgument> - <MixedAssignment occurrences="11"> + <MixedAssignment occurrences="10"> <code>$GLOBALS['currentSearchId']</code> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['num_tables']</code> <code>$GLOBALS['pos']</code> <code>$GLOBALS['savedSearch']</code> <code>$GLOBALS['savedSearchList']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['tooltip_aliasname']</code> <code>$GLOBALS['tooltip_truename']</code> @@ -1390,16 +1377,14 @@ </PossiblyInvalidCast> </file> <file src="libraries/classes/Controllers/Database/RoutinesController.php"> - <MixedArgument occurrences="2"> - <code>$GLOBALS['sub_part'] ?? ''</code> + <MixedArgument occurrences="1"> <code>$item</code> </MixedArgument> - <MixedAssignment occurrences="10"> + <MixedAssignment occurrences="9"> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['errors']</code> <code>$GLOBALS['num_tables']</code> <code>$GLOBALS['pos']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['tooltip_aliasname']</code> <code>$GLOBALS['tooltip_truename']</code> @@ -1414,14 +1399,10 @@ <InvalidArrayOffset occurrences="1"> <code>$GLOBALS['cfg']['UseDbSearch']</code> </InvalidArrayOffset> - <MixedArgument occurrences="1"> - <code>$GLOBALS['sub_part'] ?? ''</code> - </MixedArgument> - <MixedAssignment occurrences="8"> + <MixedAssignment occurrences="7"> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['num_tables']</code> <code>$GLOBALS['pos']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['tooltip_aliasname']</code> <code>$GLOBALS['tooltip_truename']</code> @@ -1845,11 +1826,10 @@ <code>$entry['statement']</code> <code>$entry['username']</code> </MixedArrayAccess> - <MixedAssignment occurrences="10"> + <MixedAssignment occurrences="9"> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['num_tables']</code> <code>$GLOBALS['pos']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['tooltip_aliasname']</code> <code>$GLOBALS['tooltip_truename']</code> @@ -1885,15 +1865,11 @@ </PossiblyNullIterator> </file> <file src="libraries/classes/Controllers/Database/TriggersController.php"> - <MixedArgument occurrences="1"> - <code>$GLOBALS['sub_part'] ?? ''</code> - </MixedArgument> - <MixedAssignment occurrences="9"> + <MixedAssignment occurrences="8"> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['errors']</code> <code>$GLOBALS['num_tables']</code> <code>$GLOBALS['pos']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['tooltip_aliasname']</code> <code>$GLOBALS['tooltip_truename']</code> @@ -2607,22 +2583,17 @@ </MixedArgument> </file> <file src="libraries/classes/Controllers/Server/BinlogController.php"> - <MixedAssignment occurrences="1"> - <code>$GLOBALS['errorUrl']</code> + <MixedArgument occurrences="2"> + <code>$log</code> + <code>$log ?? ''</code> + </MixedArgument> + <MixedAssignment occurrences="2"> + <code>$log</code> + <code>$urlParams['log']</code> </MixedAssignment> - <PossiblyInvalidArgument occurrences="2"> - <code>$params['log']</code> - <code>$params['log'] ?? ''</code> - </PossiblyInvalidArgument> - <PossiblyInvalidCast occurrences="1"> - <code>$params['log'] ?? ''</code> - </PossiblyInvalidCast> <RedundantCast occurrences="1"> <code>(int) $GLOBALS['cfg']['MaxRows']</code> </RedundantCast> - <RiskyCast occurrences="1"> - <code>$params['pos']</code> - </RiskyCast> </file> <file src="libraries/classes/Controllers/Server/Databases/CreateController.php"> <MixedAssignment occurrences="1"> @@ -2790,7 +2761,7 @@ <MixedArgumentTypeCoercion occurrences="1"> <code>$GLOBALS['queries']</code> </MixedArgumentTypeCoercion> - <MixedAssignment occurrences="29"> + <MixedAssignment occurrences="28"> <code>$GLOBALS['_add_user_error']</code> <code>$GLOBALS['db_and_table']</code> <code>$GLOBALS['dbname']</code> @@ -2811,7 +2782,6 @@ <code>$GLOBALS['ret_message']</code> <code>$GLOBALS['ret_queries']</code> <code>$GLOBALS['routinename']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['tablename']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['title']</code> @@ -3601,9 +3571,6 @@ </PossiblyInvalidOperand> </file> <file src="libraries/classes/Controllers/Table/OperationsController.php"> - <InvalidArgument occurrences="1"> - <code>$_POST['partition_name']</code> - </InvalidArgument> <MixedArgument occurrences="7"> <code>$GLOBALS['create_options']['pack_keys']</code> <code>$GLOBALS['create_options']['page_checksum'] ?? ''</code> @@ -3613,8 +3580,9 @@ <code>$_message</code> <code>$_message</code> </MixedArgument> - <MixedArgumentTypeCoercion occurrences="1"> + <MixedArgumentTypeCoercion occurrences="2"> <code>$GLOBALS['table_alters']</code> + <code>is_array($partitionNames) ? $partitionNames : []</code> </MixedArgumentTypeCoercion> <MixedArrayAccess occurrences="1"> <code>$GLOBALS['showtable']['Row_format']</code> @@ -3652,29 +3620,6 @@ <MixedMethodCall occurrences="1"> <code>getList</code> </MixedMethodCall> - <PossiblyInvalidArgument occurrences="10"> - <code>$_POST['db']</code> - <code>$_POST['new_name']</code> - <code>$_POST['new_name']</code> - <code>$_POST['new_name']</code> - <code>$_POST['new_tbl_storage_engine']</code> - <code>$_POST['new_tbl_storage_engine']</code> - <code>$_POST['order_field']</code> - <code>$_POST['order_order'] ?? null</code> - <code>$_POST['partition_operation']</code> - <code>$_POST['tbl_collation']</code> - </PossiblyInvalidArgument> - <PossiblyInvalidCast occurrences="9"> - <code>$_POST['db']</code> - <code>$_POST['new_name']</code> - <code>$_POST['new_name']</code> - <code>$_POST['new_name']</code> - <code>$_POST['new_tbl_storage_engine']</code> - <code>$_POST['new_tbl_storage_engine']</code> - <code>$_POST['order_field']</code> - <code>$_POST['partition_operation']</code> - <code>$_POST['tbl_collation']</code> - </PossiblyInvalidCast> </file> <file src="libraries/classes/Controllers/Table/Partition/AnalyzeController.php"> <MixedArgument occurrences="1"> @@ -4028,21 +3973,9 @@ </RedundantConditionGivenDocblockType> </file> <file src="libraries/classes/Controllers/Table/Structure/PrimaryController.php"> - <MixedArgument occurrences="2"> - <code>$field</code> - <code>$selected</code> - </MixedArgument> - <MixedAssignment occurrences="6"> + <MixedAssignment occurrences="1"> <code>$GLOBALS['errorUrl']</code> - <code>$field</code> - <code>$mult_btn</code> - <code>$selected</code> - <code>$selected</code> - <code>$selected_fld</code> </MixedAssignment> - <PossiblyNullOperand occurrences="1"> - <code>$row['Column_name']</code> - </PossiblyNullOperand> </file> <file src="libraries/classes/Controllers/Table/Structure/ReservedWordCheckController.php"> <MixedArgument occurrences="1"> @@ -4234,11 +4167,9 @@ <MixedArgument occurrences="1"> <code>$version</code> </MixedArgument> - <MixedAssignment occurrences="11"> + <MixedAssignment occurrences="9"> <code>$GLOBALS['entries']</code> <code>$GLOBALS['errorUrl']</code> - <code>$GLOBALS['filter_ts_from']</code> - <code>$GLOBALS['filter_ts_to']</code> <code>$GLOBALS['filter_users']</code> <code>$GLOBALS['msg']</code> <code>$reportExport</code> @@ -4252,15 +4183,11 @@ </PossiblyNullArgument> </file> <file src="libraries/classes/Controllers/Table/TriggersController.php"> - <MixedArgument occurrences="1"> - <code>$GLOBALS['sub_part'] ?? ''</code> - </MixedArgument> - <MixedAssignment occurrences="9"> + <MixedAssignment occurrences="8"> <code>$GLOBALS['errorUrl']</code> <code>$GLOBALS['errors']</code> <code>$GLOBALS['num_tables']</code> <code>$GLOBALS['pos']</code> - <code>$GLOBALS['sub_part']</code> <code>$GLOBALS['tables']</code> <code>$GLOBALS['tooltip_aliasname']</code> <code>$GLOBALS['tooltip_truename']</code> @@ -4540,8 +4467,7 @@ <PossiblyInvalidArgument occurrences="1"> <code>$post_key</code> </PossiblyInvalidArgument> - <PossiblyInvalidCast occurrences="2"> - <code>$_ENV[$var_name]</code> + <PossiblyInvalidCast occurrences="1"> <code>$_SERVER[$var_name]</code> </PossiblyInvalidCast> <PossiblyNullReference occurrences="1"> @@ -8061,14 +7987,13 @@ <MixedArrayOffset occurrences="1"> <code>$columns['sub_parts'][$key]</code> </MixedArrayOffset> - <MixedAssignment occurrences="15"> + <MixedAssignment occurrences="14"> <code>$column</code> <code>$key</code> <code>$name</code> <code>$sub_part</code> <code>$this->choice</code> <code>$this->comment</code> - <code>$this->keyBlockSize</code> <code>$this->name</code> <code>$this->nonUnique</code> <code>$this->packed</code> @@ -8081,9 +8006,7 @@ <PossiblyNullOperand occurrences="1"> <code>$params['Seq_in_index']</code> </PossiblyNullOperand> - <PossiblyNullPropertyAssignmentValue occurrences="3"> - <code>null</code> - <code>null</code> + <PossiblyNullPropertyAssignmentValue occurrences="1"> <code>null</code> </PossiblyNullPropertyAssignmentValue> <RedundantCastGivenDocblockType occurrences="1"> @@ -13465,10 +13388,7 @@ </PossiblyNullArgument> </file> <file src="libraries/classes/Table.php"> - <DeprecatedMethod occurrences="52"> - <code>escapeString</code> - <code>escapeString</code> - <code>escapeString</code> + <DeprecatedMethod occurrences="49"> <code>escapeString</code> <code>escapeString</code> <code>escapeString</code> @@ -13643,7 +13563,7 @@ <code>$optionsArray[$existrelForeign[$masterFieldMd5]['on_delete'] ?? '']</code> <code>$optionsArray[$existrelForeign[$masterFieldMd5]['on_update'] ?? '']</code> </MixedArrayTypeCoercion> - <MixedAssignment occurrences="48"> + <MixedAssignment occurrences="47"> <code>$GLOBALS['errorUrl']</code> <code>$cachedResult</code> <code>$cachedResult</code> @@ -13654,7 +13574,6 @@ <code>$constraintName</code> <code>$createTable</code> <code>$currCreateTime</code> - <code>$e</code> <code>$eachCol</code> <code>$foreignDb</code> <code>$foreignDb</code> @@ -14559,12 +14478,10 @@ <code>mb_strpos($value, '.')</code> <code>mb_strrpos($columnSpecification, ')')</code> </PossiblyFalseOperand> - <PossiblyInvalidArgument occurrences="5"> + <PossiblyInvalidArgument occurrences="3"> <code>$sep</code> <code>$sep</code> <code>$table</code> - <code>$tableType</code> - <code>$tableType</code> </PossiblyInvalidArgument> <PossiblyInvalidArrayAccess occurrences="2"> <code>$group[$groupName]['tab' . $sep . 'count']</code> @@ -14582,7 +14499,7 @@ <code>$sep</code> <code>$sep</code> </PossiblyInvalidCast> - <PossiblyInvalidOperand occurrences="12"> + <PossiblyInvalidOperand occurrences="11"> <code>$GLOBALS['cfg']['NavigationTreeTableSeparator']</code> <code>$GLOBALS['cfg']['NavigationTreeTableSeparator']</code> <code>$sep</code> @@ -14594,7 +14511,6 @@ <code>$sep</code> <code>$sep</code> <code>$sep</code> - <code>$tableGroup</code> </PossiblyInvalidOperand> <PossiblyNullArgument occurrences="2"> <code>$maxSize</code> @@ -14625,9 +14541,6 @@ <RedundantCondition occurrences="1"> <code>$columnsList !== null</code> </RedundantCondition> - <RiskyCast occurrences="1"> - <code>$_REQUEST['pos']</code> - </RiskyCast> </file> <file src="libraries/classes/Utils/ForeignKey.php"> <RedundantCastGivenDocblockType occurrences="1"> diff --git a/test/classes/Controllers/Database/StructureControllerTest.php b/test/classes/Controllers/Database/StructureControllerTest.php index 1cd678f816..e96f14c6d2 100644 --- a/test/classes/Controllers/Database/StructureControllerTest.php +++ b/test/classes/Controllers/Database/StructureControllerTest.php @@ -9,6 +9,7 @@ use PhpMyAdmin\ConfigStorage\RelationCleanup; use PhpMyAdmin\Controllers\Database\StructureController; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\FlashMessages; +use PhpMyAdmin\Http\ServerRequest; use PhpMyAdmin\Operations; use PhpMyAdmin\Replication; use PhpMyAdmin\Table; @@ -448,7 +449,7 @@ class StructureControllerTest extends AbstractTestCase $structureController, StructureController::class, 'getDatabaseInfo', - [''] + [$this->createStub(ServerRequest::class)] ); $this->assertSame( diff --git a/test/classes/Controllers/Server/BinlogControllerTest.php b/test/classes/Controllers/Server/BinlogControllerTest.php index abd9418a42..8b543e35c7 100644 --- a/test/classes/Controllers/Server/BinlogControllerTest.php +++ b/test/classes/Controllers/Server/BinlogControllerTest.php @@ -53,10 +53,13 @@ class BinlogControllerTest extends AbstractTestCase $controller = new BinlogController($response, new Template(), $GLOBALS['dbi']); - $_POST['log'] = 'index1'; - $_POST['pos'] = '3'; + $request = $this->createStub(ServerRequest::class); + $request->method('getParsedBodyParam')->willReturnMap([ + ['log', null, 'index1'], + ['pos', 0, '3'], + ]); $this->dummyDbi->addSelectDb('mysql'); - $controller($this->createStub(ServerRequest::class)); + $controller($request); $this->dummyDbi->assertAllSelectsConsumed(); $actual = $response->getHTMLResult(); diff --git a/test/classes/TableTest.php b/test/classes/TableTest.php index bfb642cf57..434b66f8f0 100644 --- a/test/classes/TableTest.php +++ b/test/classes/TableTest.php @@ -1308,7 +1308,7 @@ class TableTest extends AbstractTestCase $table = new Table($table, $db, $GLOBALS['dbi']); $sql = $table->getSqlQueryForIndexCreateOrEdit($index, $error); - $this->assertEquals('ALTER TABLE `pma_db`.`pma_table` DROP PRIMARY KEY, ADD UNIQUE ;', $sql); + $this->assertEquals('ALTER TABLE `pma_db`.`pma_table` DROP PRIMARY KEY, ADD UNIQUE;', $sql); } /** @@ -1326,7 +1326,7 @@ class TableTest extends AbstractTestCase $table = new Table($table, $db, $GLOBALS['dbi']); $sql = $table->getSqlQueryForIndexCreateOrEdit($index, $error); - $this->assertEquals('ALTER TABLE `pma_db`.`pma_table` DROP PRIMARY KEY, ADD UNIQUE ;', $sql); + $this->assertEquals('ALTER TABLE `pma_db`.`pma_table` DROP PRIMARY KEY, ADD UNIQUE;', $sql); } /** diff --git a/test/classes/TrackingTest.php b/test/classes/TrackingTest.php index c677bfd342..3238241344 100644 --- a/test/classes/TrackingTest.php +++ b/test/classes/TrackingTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests; +use DateTimeImmutable; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\ConfigStorage\RelationParameters; use PhpMyAdmin\SqlQueryForm; @@ -65,21 +66,24 @@ class TrackingTest extends AbstractTestCase { $data = [ [ - 'date' => '20120102', + 'date' => '2012-01-01 12:34:56', 'username' => 'username1', 'statement' => 'statement1', ], [ - 'date' => '20130102', + 'date' => '2013-01-01 12:34:56', 'username' => 'username2', 'statement' => 'statement2', ], ]; - $filter_ts_from = 0; - $filter_ts_to = 999999999999; $filter_users = ['username1']; - $ret = $this->tracking->filter($data, $filter_ts_from, $filter_ts_to, $filter_users); + $ret = $this->tracking->filter( + $data, + $filter_users, + new DateTimeImmutable('2010-01-01 12:34:56'), + new DateTimeImmutable('2020-01-01 12:34:56') + ); $this->assertEquals('username1', $ret[0]['username']); $this->assertEquals('statement1', $ret[0]['statement']); @@ -274,20 +278,16 @@ class TrackingTest extends AbstractTestCase 'dmlog' => [['date' => '2022-11-02 22:15:24']], ]; $url_params = []; - $filter_ts_to = 0; - $filter_ts_from = 0; $filter_users = []; $html = $this->tracking->getHtmlForTrackingReport( $data, $url_params, 'schema_and_data', - $filter_ts_to, - $filter_ts_from, $filter_users, '10', - '2022-11-03 22:15:24', - '2022-11-04 22:15:24', + new DateTimeImmutable('2022-11-03 22:15:24'), + new DateTimeImmutable('2022-11-04 22:15:24'), 'users' ); @@ -342,7 +342,7 @@ class TrackingTest extends AbstractTestCase 'dmlog' => [ [ 'statement' => 'statement', - 'date' => 'date', + 'date' => '2013-01-01 12:34:56', 'username' => 'username', ], ], @@ -351,19 +351,17 @@ class TrackingTest extends AbstractTestCase $url_params = []; $ddlog_count = 10; $drop_image_or_text = 'text'; - $filter_ts_to = 9999999999; - $filter_ts_from = 0; $filter_users = ['*']; $html = $this->tracking->getHtmlForDataManipulationStatements( $data, $filter_users, - $filter_ts_from, - $filter_ts_to, $url_params, $ddlog_count, $drop_image_or_text, - '10' + '10', + new DateTimeImmutable('2010-01-01 12:34:56'), + new DateTimeImmutable('2020-01-01 12:34:56') ); $this->assertStringContainsString( @@ -396,26 +394,24 @@ class TrackingTest extends AbstractTestCase 'ddlog' => [ [ 'statement' => 'statement', - 'date' => 'date', + 'date' => '2013-01-01 12:34:56', 'username' => 'username', ], ], 'dmlog' => ['dmlog'], ]; $filter_users = ['*']; - $filter_ts_to = 9999999999; - $filter_ts_from = 0; $url_params = []; $drop_image_or_text = 'text'; [$html, $count] = $this->tracking->getHtmlForDataDefinitionStatements( $data, $filter_users, - $filter_ts_from, - $filter_ts_to, $url_params, $drop_image_or_text, - '10' + '10', + new DateTimeImmutable('2010-01-01 12:34:56'), + new DateTimeImmutable('2020-01-01 12:34:56') ); $this->assertStringContainsString( @@ -564,23 +560,27 @@ class TrackingTest extends AbstractTestCase 'ddlog' => [ [ 'statement' => 'statement1', - 'date' => 'date2', + 'date' => '2012-01-01 12:34:56', 'username' => 'username3', ], ], 'dmlog' => [ [ 'statement' => 'statement1', - 'date' => 'date2', + 'date' => '2013-01-01 12:34:56', 'username' => 'username3', ], ], ]; $filter_users = ['*']; - $filter_ts_to = 9999999999; - $filter_ts_from = 0; - $entries = $this->tracking->getEntries($data, $filter_ts_from, $filter_ts_to, $filter_users, 'schema'); + $entries = $this->tracking->getEntries( + $data, + $filter_users, + 'schema', + new DateTimeImmutable('2010-01-01 12:34:56'), + new DateTimeImmutable('2020-01-01 12:34:56') + ); $this->assertEquals('username3', $entries[0]['username']); $this->assertEquals('statement1', $entries[0]['statement']); } diff --git a/test/classes/UtilTest.php b/test/classes/UtilTest.php index 728e7a682f..78da6fa430 100644 --- a/test/classes/UtilTest.php +++ b/test/classes/UtilTest.php @@ -6,6 +6,7 @@ namespace PhpMyAdmin\Tests; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\FieldMetadata; +use PhpMyAdmin\Http\ServerRequest; use PhpMyAdmin\MoTranslator\Loader; use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; @@ -2545,8 +2546,8 @@ class UtilTest extends AbstractTestCase 'TABLE_COMMENT' => '', 'TABLE_TYPE' => 'BASE TABLE', ]; - $expected = [['test_table' => $tableInfo], 1, 1, '_structure', true, false, [], [], 0]; - $actual = Util::getDbInfo('test_db', ''); + $expected = [['test_table' => $tableInfo], 1, 1, true, false, [], [], 0]; + $actual = Util::getDbInfo($this->createStub(ServerRequest::class), 'test_db'); $this->assertSame($expected, $actual); } |