From 8e1dd72448aed592d0e159b8ec96cda60e4136e9 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 15 Dec 2023 16:15:05 +0100 Subject: [PATCH 1/6] Remove $GLOBALS['find_real_end'] Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 51 +++++++------------ src/Controllers/Import/ImportController.php | 1 - src/Controllers/Sql/SqlController.php | 9 ---- .../Table/DeleteRowsController.php | 1 - src/Controllers/Table/SearchController.php | 1 - .../Table/Structure/BrowseController.php | 1 - src/Database/MultiTableQuery.php | 1 - src/Sql.php | 32 ++---------- tests/classes/SqlTest.php | 4 -- 9 files changed, 21 insertions(+), 80 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c4a05ac23a..72b9df3057 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3516,7 +3516,7 @@ parameters: path: src/Controllers/Import/ImportController.php - - message: "#^Parameter \\#12 \\$sqlQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndGetQueryResponse\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#11 \\$sqlQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndGetQueryResponse\\(\\) expects string, mixed given\\.$#" count: 1 path: src/Controllers/Import/ImportController.php @@ -3606,7 +3606,7 @@ parameters: path: src/Controllers/Import/ImportController.php - - message: "#^Parameter \\#9 \\$goto of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndGetQueryResponse\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#8 \\$goto of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndGetQueryResponse\\(\\) expects string, mixed given\\.$#" count: 1 path: src/Controllers/Import/ImportController.php @@ -5220,11 +5220,6 @@ parameters: count: 1 path: src/Controllers/Sql/SqlController.php - - - message: "#^Parameter \\#1 \\$db of method PhpMyAdmin\\\\Sql\\:\\:findRealEndOfRows\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#1 \\$db of method PhpMyAdmin\\\\Sql\\:\\:getDefaultSqlQueryForBrowse\\(\\) expects string, mixed given\\.$#" count: 1 @@ -5266,22 +5261,17 @@ parameters: path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#10 \\$dispQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string\\|null, mixed given\\.$#" + message: "#^Parameter \\#10 \\$dispMessage of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects PhpMyAdmin\\\\Message\\|string\\|null, mixed given\\.$#" count: 1 path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#11 \\$dispMessage of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects PhpMyAdmin\\\\Message\\|string\\|null, mixed given\\.$#" + message: "#^Parameter \\#11 \\$sqlQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string, mixed given\\.$#" count: 1 path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#12 \\$sqlQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Controllers/Sql/SqlController.php - - - - message: "#^Parameter \\#13 \\$completeQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string\\|null, mixed given\\.$#" + message: "#^Parameter \\#12 \\$completeQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string\\|null, mixed given\\.$#" count: 1 path: src/Controllers/Sql/SqlController.php @@ -5300,11 +5290,6 @@ parameters: count: 1 path: src/Controllers/Sql/SqlController.php - - - message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\Sql\\:\\:findRealEndOfRows\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\Sql\\:\\:getDefaultSqlQueryForBrowse\\(\\) expects string, mixed given\\.$#" count: 1 @@ -5326,22 +5311,22 @@ parameters: path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#5 \\$findRealEnd of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects bool\\|null, mixed given\\.$#" + message: "#^Parameter \\#5 \\$sqlQueryForBookmark of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string\\|null, mixed given\\.$#" count: 1 path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#6 \\$sqlQueryForBookmark of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string\\|null, mixed given\\.$#" + message: "#^Parameter \\#6 \\$messageToShow of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string\\|null, mixed given\\.$#" count: 1 path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#7 \\$messageToShow of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string\\|null, mixed given\\.$#" + message: "#^Parameter \\#8 \\$goto of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string, mixed given\\.$#" count: 1 path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#9 \\$goto of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#9 \\$dispQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string\\|null, mixed given\\.$#" count: 1 path: src/Controllers/Sql/SqlController.php @@ -5821,17 +5806,12 @@ parameters: path: src/Controllers/Table/DeleteRowsController.php - - message: "#^Parameter \\#10 \\$dispQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string\\|null, mixed given\\.$#" + message: "#^Parameter \\#10 \\$dispMessage of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects PhpMyAdmin\\\\Message\\|string\\|null, mixed given\\.$#" count: 1 path: src/Controllers/Table/DeleteRowsController.php - - message: "#^Parameter \\#11 \\$dispMessage of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects PhpMyAdmin\\\\Message\\|string\\|null, mixed given\\.$#" - count: 1 - path: src/Controllers/Table/DeleteRowsController.php - - - - message: "#^Parameter \\#12 \\$sqlQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#11 \\$sqlQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string, mixed given\\.$#" count: 1 path: src/Controllers/Table/DeleteRowsController.php @@ -5861,7 +5841,12 @@ parameters: path: src/Controllers/Table/DeleteRowsController.php - - message: "#^Parameter \\#9 \\$goto of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#8 \\$goto of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Controllers/Table/DeleteRowsController.php + + - + message: "#^Parameter \\#9 \\$dispQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string\\|null, mixed given\\.$#" count: 1 path: src/Controllers/Table/DeleteRowsController.php @@ -6871,7 +6856,7 @@ parameters: path: src/Controllers/Table/SearchController.php - - message: "#^Parameter \\#9 \\$goto of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#8 \\$goto of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects string, mixed given\\.$#" count: 1 path: src/Controllers/Table/SearchController.php diff --git a/src/Controllers/Import/ImportController.php b/src/Controllers/Import/ImportController.php index 92075ddc2b..a91cbc5cad 100644 --- a/src/Controllers/Import/ImportController.php +++ b/src/Controllers/Import/ImportController.php @@ -723,7 +723,6 @@ final class ImportController extends AbstractController false, // is_gotofile $GLOBALS['db'], // db $GLOBALS['table'], // table - null, // find_real_end null, // sql_query_for_bookmark - see below null, // message_to_show null, // sql_data diff --git a/src/Controllers/Sql/SqlController.php b/src/Controllers/Sql/SqlController.php index dc3e27babb..da793d164f 100644 --- a/src/Controllers/Sql/SqlController.php +++ b/src/Controllers/Sql/SqlController.php @@ -47,7 +47,6 @@ class SqlController extends AbstractController $GLOBALS['ajax_reload'] ??= null; $GLOBALS['goto'] ??= null; $GLOBALS['errorUrl'] ??= null; - $GLOBALS['find_real_end'] ??= null; $GLOBALS['unlim_num_rows'] ??= null; $GLOBALS['import_text'] ??= null; $GLOBALS['disp_query'] ??= null; @@ -172,13 +171,6 @@ class SqlController extends AbstractController ); } - /** - * Need to find the real end of rows? - */ - if (isset($GLOBALS['find_real_end']) && $GLOBALS['find_real_end']) { - $GLOBALS['unlim_num_rows'] = $this->sql->findRealEndOfRows($GLOBALS['db'], $GLOBALS['table']); - } - /** * Bookmark add */ @@ -207,7 +199,6 @@ class SqlController extends AbstractController $GLOBALS['is_gotofile'], $GLOBALS['db'], $GLOBALS['table'], - $GLOBALS['find_real_end'] ?? null, $GLOBALS['import_text'] ?? null, $GLOBALS['message_to_show'] ?? null, null, diff --git a/src/Controllers/Table/DeleteRowsController.php b/src/Controllers/Table/DeleteRowsController.php index daa853aa34..6a66342da2 100644 --- a/src/Controllers/Table/DeleteRowsController.php +++ b/src/Controllers/Table/DeleteRowsController.php @@ -92,7 +92,6 @@ final class DeleteRowsController extends AbstractController null, null, null, - null, $GLOBALS['goto'] ?? '', $GLOBALS['disp_query'] ?? null, $GLOBALS['disp_message'] ?? null, diff --git a/src/Controllers/Table/SearchController.php b/src/Controllers/Table/SearchController.php index 1981253828..1ef6f2661e 100644 --- a/src/Controllers/Table/SearchController.php +++ b/src/Controllers/Table/SearchController.php @@ -282,7 +282,6 @@ class SearchController extends AbstractController false, // is_gotofile $GLOBALS['db'], // db $GLOBALS['table'], // table - null, // find_real_end null, // sql_query_for_bookmark null, // message_to_show null, // sql_data diff --git a/src/Controllers/Table/Structure/BrowseController.php b/src/Controllers/Table/Structure/BrowseController.php index 3cad05cbc2..faa8fd5ea8 100644 --- a/src/Controllers/Table/Structure/BrowseController.php +++ b/src/Controllers/Table/Structure/BrowseController.php @@ -65,7 +65,6 @@ final class BrowseController extends AbstractController false, // is_gotofile $GLOBALS['db'], // db $GLOBALS['table'], // table - null, // find_real_end null, // sql_query_for_bookmark null, // message_to_show null, // sql_data diff --git a/src/Database/MultiTableQuery.php b/src/Database/MultiTableQuery.php index e54d632dde..762d9872a9 100644 --- a/src/Database/MultiTableQuery.php +++ b/src/Database/MultiTableQuery.php @@ -91,7 +91,6 @@ class MultiTableQuery false, // is_gotofile $db, // db null, // table - null, // find_real_end null, // sql_query_for_bookmark - see below null, // message_to_show null, // sql_data diff --git a/src/Sql.php b/src/Sql.php index 069b71a6d9..70d8b26bb5 100644 --- a/src/Sql.php +++ b/src/Sql.php @@ -369,10 +369,8 @@ class Sql /** * Function to check whether this query is for just browsing - * - * @param bool|null $findRealEnd whether the real end should be found */ - public static function isJustBrowsing(StatementInfo $statementInfo, bool|null $findRealEnd): bool + public static function isJustBrowsing(StatementInfo $statementInfo, bool $findRealEnd = false): bool { return ! $statementInfo->isGroup && ! $statementInfo->isFunction @@ -384,7 +382,7 @@ class Sql || (count($statementInfo->statement->where) === 1 && $statementInfo->statement->where[0]->expr === '1')) && ! $statementInfo->group - && ! isset($findRealEnd) + && ! $findRealEnd && ! $statementInfo->isSubquery && ! $statementInfo->join && ! $statementInfo->having; @@ -412,22 +410,6 @@ class Sql return ! $allowUserDropDatabase && $statementInfo->dropDatabase && ! $isSuperUser; } - /** - * Function to find the real end of rows - * - * @param string $db the current database - * @param string $table the current table - * - * @return int the number of rows - */ - public function findRealEndOfRows(string $db, string $table): int - { - $unlimNumRows = $this->dbi->getTable($db, $table)->countRecords(true); - $_SESSION['tmpval']['pos'] = $this->getStartPosToDisplayRow($unlimNumRows); - - return $unlimNumRows; - } - /** * Function to get the default sql query for browsing page * @@ -717,7 +699,6 @@ class Sql * @param bool $isGotoFile whether to go to a file * @param string $db current database * @param string|null $table current table - * @param bool|null $findRealEnd whether to find the real end * @param string|null $sqlQueryForBookmark sql query to be stored as bookmark * * @psalm-return array{ @@ -734,7 +715,6 @@ class Sql bool $isGotoFile, string $db, string|null $table, - bool|null $findRealEnd, string|null $sqlQueryForBookmark, ): array { $response = ResponseRenderer::getInstance(); @@ -787,7 +767,7 @@ class Sql $profilingResults = Profiling::getInformation($this->dbi); - $justBrowsing = self::isJustBrowsing($statementInfo, $findRealEnd ?? null); + $justBrowsing = self::isJustBrowsing($statementInfo); $unlimNumRows = $this->countQueryResults($numRows, $justBrowsing, $db, $table ?? '', $statementInfo); @@ -1469,7 +1449,6 @@ class Sql * @param bool $isGotoFile whether goto file or not * @param string $db current database * @param string|null $table current table - * @param bool|null $findRealEnd whether to find real end or not * @param string|null $sqlQueryForBookmark the sql query to be stored as bookmark * @param string|null $messageToShow message to show * @param mixed[]|null $sqlData sql data @@ -1484,7 +1463,6 @@ class Sql bool $isGotoFile, string $db, string|null $table, - bool|null $findRealEnd, string|null $sqlQueryForBookmark, string|null $messageToShow, array|null $sqlData, @@ -1506,7 +1484,6 @@ class Sql $isGotoFile, // is_gotofile $db, // db $table, // table - $findRealEnd, // find_real_end $sqlQueryForBookmark, // sql_query_for_bookmark $messageToShow, // message_to_show $sqlData, // sql_data @@ -1524,7 +1501,6 @@ class Sql * @param bool $isGotoFile whether goto file or not * @param string $db current database * @param string|null $table current table - * @param bool|null $findRealEnd whether to find real end or not * @param string|null $sqlQueryForBookmark the sql query to be stored as bookmark * @param string|null $messageToShow message to show * @param mixed[]|null $sqlData sql data @@ -1541,7 +1517,6 @@ class Sql bool $isGotoFile, string $db, string|null $table, - bool|null $findRealEnd, string|null $sqlQueryForBookmark, string|null $messageToShow, array|null $sqlData, @@ -1611,7 +1586,6 @@ class Sql $isGotoFile, $db, $table, - $findRealEnd, $sqlQueryForBookmark, ); diff --git a/tests/classes/SqlTest.php b/tests/classes/SqlTest.php index f06eec62b5..4362b2fb29 100644 --- a/tests/classes/SqlTest.php +++ b/tests/classes/SqlTest.php @@ -159,17 +159,14 @@ class SqlTest extends AbstractTestCase $this->assertTrue(Sql::isJustBrowsing( ParseAnalyze::sqlQuery('SELECT * FROM db.tbl', $GLOBALS['db'])[0], - null, )); $this->assertTrue(Sql::isJustBrowsing( ParseAnalyze::sqlQuery('SELECT * FROM tbl WHERE 1', $GLOBALS['db'])[0], - null, )); $this->assertFalse(Sql::isJustBrowsing( ParseAnalyze::sqlQuery('SELECT * from tbl1, tbl2 LIMIT 0, 10', $GLOBALS['db'])[0], - null, )); } @@ -607,7 +604,6 @@ class SqlTest extends AbstractTestCase null, null, null, - null, 'index.php?route=/sql', null, null, From d204a758fd1fe223df87dbfd07c7e21916922299 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 15 Dec 2023 19:31:10 +0100 Subject: [PATCH 2/6] Remove $GLOBALS['showtable'] Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 32 +++----- psalm-baseline.xml | 78 +++++++----------- .../templates/display/results/table.twig | 3 - .../Operations/TableController.php | 6 +- src/Controllers/Table/StructureController.php | 81 ++++++++++--------- src/Display/Results.php | 69 +++++----------- src/Sql.php | 17 ---- src/Table/Table.php | 4 +- .../Table/DeleteRowsControllerTest.php | 1 - .../Table/ReplaceControllerTest.php | 1 - tests/classes/Display/ResultsTest.php | 2 - tests/classes/SqlTest.php | 1 - 12 files changed, 107 insertions(+), 188 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 72b9df3057..b65cb4eb0c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -7440,6 +7440,11 @@ parameters: count: 2 path: src/Controllers/Table/StructureController.php + - + message: "#^Cannot access offset 'Name' on mixed\\.$#" + count: 1 + path: src/Controllers/Table/StructureController.php + - message: "#^Cannot access offset 'Rows' on mixed\\.$#" count: 1 @@ -7525,6 +7530,11 @@ parameters: count: 1 path: src/Controllers/Table/StructureController.php + - + message: "#^Parameter \\#1 \\$showTableName of method PhpMyAdmin\\\\Table\\\\Table\\:\\:getNumRows\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Controllers/Table/StructureController.php + - message: "#^Parameter \\#1 \\$table of static method PhpMyAdmin\\\\Index\\:\\:findDuplicates\\(\\) expects string, mixed given\\.$#" count: 1 @@ -17137,7 +17147,7 @@ parameters: - message: "#^Cannot access offset 'pos' on mixed\\.$#" - count: 4 + count: 3 path: src/Sql.php - @@ -17270,11 +17280,6 @@ parameters: count: 1 path: src/Sql.php - - - message: "#^Parameter \\#13 \\$showTable of method PhpMyAdmin\\\\Display\\\\Results\\:\\:setProperties\\(\\) expects array\\\\|null, array\\|null given\\.$#" - count: 2 - path: src/Sql.php - - message: "#^Parameter \\#2 \\$db of class PhpMyAdmin\\\\Display\\\\Results constructor expects string, mixed given\\.$#" count: 1 @@ -17335,11 +17340,6 @@ parameters: count: 1 path: src/Sql.php - - - message: "#^Parameter \\#6 \\$showTable of method PhpMyAdmin\\\\Sql\\:\\:getHtmlForSqlQueryResultsTable\\(\\) expects array\\|null, mixed given\\.$#" - count: 1 - path: src/Sql.php - - message: "#^Parameter \\#6 \\$sqlQuery of class PhpMyAdmin\\\\Display\\\\Results constructor expects string, mixed given\\.$#" count: 1 @@ -17750,11 +17750,6 @@ parameters: count: 3 path: src/Table/Table.php - - - message: "#^Cannot access offset 'Name' on mixed\\.$#" - count: 1 - path: src/Table/Table.php - - message: "#^Cannot access offset 'Type' on mixed\\.$#" count: 2 @@ -18025,11 +18020,6 @@ parameters: count: 1 path: src/Table/Table.php - - - message: "#^Parameter \\#2 \\$tableName of method PhpMyAdmin\\\\DatabaseInterface\\:\\:getTable\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Table/Table.php - - message: "#^Parameter \\#3 \\$foreignDb of method PhpMyAdmin\\\\Table\\\\Table\\:\\:getSQLToCreateForeignKey\\(\\) expects string, mixed given\\.$#" count: 2 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 5568549efb..b9e09ac572 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2402,15 +2402,15 @@ is_array($partitionNames) ? $partitionNames : [] - + - - $rereadInfo + $showTable + $showTable __construct @@ -3207,7 +3207,6 @@ - @@ -3217,7 +3216,6 @@ - @@ -3234,7 +3232,6 @@ - @@ -4105,55 +4102,48 @@ - - - - - - - - - - + + + + + + + + + + + - - - + + - - + + - - $attributes[$rownum] $rereadInfo + $showTable + $showTable - - - - - icon]]> icon]]> + + + + + - - - - - - - @@ -11326,10 +11316,6 @@ $sortCol expr]]> - - $showTable - $showTable - @@ -11341,7 +11327,6 @@ statement->where[0]]]> - expr[0]]]> @@ -11876,7 +11861,6 @@ - diff --git a/resources/templates/display/results/table.twig b/resources/templates/display/results/table.twig index 72e6a3bf9f..8780b7ec3f 100644 --- a/resources/templates/display/results/table.twig +++ b/resources/templates/display/results/table.twig @@ -68,9 +68,6 @@ - {% if navigation.has_real_end_input %} - - {% endif %} {% set end_text %} {%- if show_text('TableNavigationLinksMode') -%} {% trans %}End{% context %}Last page{% endtrans %}  diff --git a/src/Controllers/Operations/TableController.php b/src/Controllers/Operations/TableController.php index 39cd46c6c2..3aa13a0626 100644 --- a/src/Controllers/Operations/TableController.php +++ b/src/Controllers/Operations/TableController.php @@ -118,7 +118,7 @@ class TableController extends AbstractController $this->dbi->selectDb($GLOBALS['db']); $rereadInfo = $pmaTable->getStatusInfo(); - $GLOBALS['showtable'] = $pmaTable->getStatusInfo(null, ! empty($rereadInfo)); + $showTable = $pmaTable->getStatusInfo(null, ! empty($rereadInfo)); if ($pmaTable->isView()) { $tableIsAView = true; $tableStorageEngine = __('View'); @@ -327,7 +327,7 @@ class TableController extends AbstractController // a change, clear the cache $this->dbi->getCache()->clearTableCache(); $this->dbi->selectDb($GLOBALS['db']); - $GLOBALS['showtable'] = $pmaTable->getStatusInfo(null, true); + $showTable = $pmaTable->getStatusInfo(null, true); if ($pmaTable->isView()) { $tableIsAView = true; $tableStorageEngine = __('View'); @@ -501,7 +501,7 @@ class TableController extends AbstractController 'collations' => $collations, 'tbl_collation' => $tableCollation, 'row_formats' => $possibleRowFormats[$tableStorageEngine] ?? [], - 'row_format_current' => $GLOBALS['showtable']['Row_format'], + 'row_format_current' => $showTable['Row_format'], 'has_auto_increment' => $hasAutoIncrement, 'auto_increment' => $GLOBALS['auto_increment'], 'has_pack_keys' => $hasPackKeys, diff --git a/src/Controllers/Table/StructureController.php b/src/Controllers/Table/StructureController.php index e4652c84fd..bf0c3dfe0f 100644 --- a/src/Controllers/Table/StructureController.php +++ b/src/Controllers/Table/StructureController.php @@ -65,12 +65,11 @@ class StructureController extends AbstractController public function __invoke(ServerRequest $request): void { - $GLOBALS['showtable'] ??= null; $GLOBALS['errorUrl'] ??= null; $this->dbi->selectDb($GLOBALS['db']); $rereadInfo = $this->tableObj->getStatusInfo(null, true); - $GLOBALS['showtable'] = $this->tableObj->getStatusInfo(null, ! empty($rereadInfo)); + $showTable = $this->tableObj->getStatusInfo(null, ! empty($rereadInfo)); $this->pageSettings->init('TableStructure'); $this->response->addHTML($this->pageSettings->getErrorHTML()); @@ -141,6 +140,7 @@ class StructureController extends AbstractController $columnsWithIndex, $isSystemSchema, $request->getRoute(), + $showTable, )); } @@ -160,6 +160,7 @@ class StructureController extends AbstractController array $columnsWithIndex, bool $isSystemSchema, string $route, + mixed $showTable, ): string { if ($this->tableObj->isView()) { $tableIsAView = true; @@ -191,7 +192,7 @@ class StructureController extends AbstractController // Get valid statistics whatever is the table type if ($config->settings['ShowStats']) { //get table stats in HTML format - $tablestats = $this->getTableStats($isSystemSchema, $tableIsAView, $tableStorageEngine); + $tablestats = $this->getTableStats($isSystemSchema, $tableIsAView, $tableStorageEngine, $showTable); //returning the response in JSON format to be used by Ajax $this->response->addJSON('tableStat', $tablestats); } @@ -294,63 +295,63 @@ class StructureController extends AbstractController /** * Get HTML snippet for display table statistics */ - protected function getTableStats(bool $isSystemSchema, bool $tableIsAView, string $tableStorageEngine): string - { - $tableInfoNunRows = $this->tableObj->getNumRows(); + protected function getTableStats( + bool $isSystemSchema, + bool $tableIsAView, + string $tableStorageEngine, + mixed $showTable, + ): string { + $tableInfoNunRows = $this->tableObj->getNumRows($showTable['Name']); - if (empty($GLOBALS['showtable'])) { - $GLOBALS['showtable'] = $this->dbi->getTable($GLOBALS['db'], $GLOBALS['table'])->getStatusInfo(null, true); + if (empty($showTable)) { + $showTable = $this->dbi->getTable($GLOBALS['db'], $GLOBALS['table'])->getStatusInfo(null, true); } - if (is_string($GLOBALS['showtable'])) { - $GLOBALS['showtable'] = []; + if (is_string($showTable)) { + $showTable = []; } - if (empty($GLOBALS['showtable']['Data_length'])) { - $GLOBALS['showtable']['Data_length'] = 0; + if (empty($showTable['Data_length'])) { + $showTable['Data_length'] = 0; } - if (empty($GLOBALS['showtable']['Index_length'])) { - $GLOBALS['showtable']['Index_length'] = 0; + if (empty($showTable['Index_length'])) { + $showTable['Index_length'] = 0; } - $isInnoDB = (isset($GLOBALS['showtable']['Type']) - && $GLOBALS['showtable']['Type'] === 'InnoDB'); + $isInnoDB = (isset($showTable['Type']) + && $showTable['Type'] === 'InnoDB'); $mergetable = $this->tableObj->isMerge(); // this is to display for example 261.2 MiB instead of 268k KiB $maxDigits = 3; $decimals = 1; - [$dataSize, $dataUnit] = Util::formatByteDown($GLOBALS['showtable']['Data_length'], $maxDigits, $decimals); + [$dataSize, $dataUnit] = Util::formatByteDown($showTable['Data_length'], $maxDigits, $decimals); if ($mergetable === false) { - [$indexSize, $indexUnit] = Util::formatByteDown( - $GLOBALS['showtable']['Index_length'], - $maxDigits, - $decimals, - ); + [$indexSize, $indexUnit] = Util::formatByteDown($showTable['Index_length'], $maxDigits, $decimals); } - if (isset($GLOBALS['showtable']['Data_free'])) { - [$freeSize, $freeUnit] = Util::formatByteDown($GLOBALS['showtable']['Data_free'], $maxDigits, $decimals); + if (isset($showTable['Data_free'])) { + [$freeSize, $freeUnit] = Util::formatByteDown($showTable['Data_free'], $maxDigits, $decimals); [$effectSize, $effectUnit] = Util::formatByteDown( - $GLOBALS['showtable']['Data_length'] - + $GLOBALS['showtable']['Index_length'] - - $GLOBALS['showtable']['Data_free'], + $showTable['Data_length'] + + $showTable['Index_length'] + - $showTable['Data_free'], $maxDigits, $decimals, ); } else { [$effectSize, $effectUnit] = Util::formatByteDown( - $GLOBALS['showtable']['Data_length'] - + $GLOBALS['showtable']['Index_length'], + $showTable['Data_length'] + + $showTable['Index_length'], $maxDigits, $decimals, ); } [$totSize, $totUnit] = Util::formatByteDown( - $GLOBALS['showtable']['Data_length'] + $GLOBALS['showtable']['Index_length'], + $showTable['Data_length'] + $showTable['Index_length'], $maxDigits, $decimals, ); @@ -359,9 +360,9 @@ class StructureController extends AbstractController $avgUnit = ''; if ($tableInfoNunRows > 0) { [$avgSize, $avgUnit] = Util::formatByteDown( - ($GLOBALS['showtable']['Data_length'] - + $GLOBALS['showtable']['Index_length']) - / $GLOBALS['showtable']['Rows'], + ($showTable['Data_length'] + + $showTable['Index_length']) + / $showTable['Rows'], 6, 1, ); @@ -381,22 +382,22 @@ class StructureController extends AbstractController $tableCollation = ['name' => $collation->getName(), 'description' => $collation->getDescription()]; } - if (isset($GLOBALS['showtable']['Create_time'])) { - $GLOBALS['showtable']['Create_time'] = Util::localisedDate(strtotime($GLOBALS['showtable']['Create_time'])); + if (isset($showTable['Create_time'])) { + $showTable['Create_time'] = Util::localisedDate(strtotime($showTable['Create_time'])); } - if (isset($GLOBALS['showtable']['Update_time'])) { - $GLOBALS['showtable']['Update_time'] = Util::localisedDate(strtotime($GLOBALS['showtable']['Update_time'])); + if (isset($showTable['Update_time'])) { + $showTable['Update_time'] = Util::localisedDate(strtotime($showTable['Update_time'])); } - if (isset($GLOBALS['showtable']['Check_time'])) { - $GLOBALS['showtable']['Check_time'] = Util::localisedDate(strtotime($GLOBALS['showtable']['Check_time'])); + if (isset($showTable['Check_time'])) { + $showTable['Check_time'] = Util::localisedDate(strtotime($showTable['Check_time'])); } return $this->template->render('table/structure/display_table_stats', [ 'db' => $GLOBALS['db'], 'table' => $GLOBALS['table'], - 'showtable' => $GLOBALS['showtable'], + 'showtable' => $showTable, 'table_info_num_rows' => $tableInfoNunRows, 'tbl_is_view' => $tableIsAView, 'db_is_system_schema' => $isSystemSchema, diff --git a/src/Display/Results.php b/src/Display/Results.php index 6dc440dd84..2ffb30e989 100644 --- a/src/Display/Results.php +++ b/src/Display/Results.php @@ -20,7 +20,6 @@ use PhpMyAdmin\Plugins\Transformations\Output\Text_Plain_Sql; use PhpMyAdmin\Plugins\Transformations\Text_Plain_Link; use PhpMyAdmin\Plugins\TransformationsPlugin; use PhpMyAdmin\ResponseRenderer; -use PhpMyAdmin\Sanitize; use PhpMyAdmin\Sql; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Statements\SelectStatement; @@ -139,13 +138,6 @@ class Results */ private string|int $numRows = 0; - /** - * table definitions - * - * @var array|null - */ - private array|null $showTable = null; - /** @var bool[] */ private array $highlightColumns = []; @@ -340,23 +332,22 @@ class Results /** * Set properties which were not initialized at the constructor * - * @param int|string $unlimNumRows the total number of rows returned by the SQL query without - * any appended "LIMIT" clause programmatically - * @param FieldMetadata[] $fieldsMeta meta information about fields - * @param bool $isCount statement is SELECT COUNT - * @param bool $isExport statement contains INTO OUTFILE - * @param bool $isFunction statement contains a function like SUM() - * @param bool $isAnalyse statement contains PROCEDURE ANALYSE - * @param int|string $numRows total no. of rows returned by SQL query - * @param float $queryTime time taken for execute the SQL query - * @param string $textDirection text direction - * @param bool $isMaintenance statement contains a maintenance command - * @param bool $isExplain statement contains EXPLAIN - * @param bool $isShow statement contains SHOW - * @param array|null $showTable table definitions - * @param bool $printView print view was requested - * @param bool $editable whether the results set is editable - * @param bool $isBrowseDistinct whether browsing distinct values + * @param int|string $unlimNumRows the total number of rows returned by the SQL query without + * any appended "LIMIT" clause programmatically + * @param FieldMetadata[] $fieldsMeta meta information about fields + * @param bool $isCount statement is SELECT COUNT + * @param bool $isExport statement contains INTO OUTFILE + * @param bool $isFunction statement contains a function like SUM() + * @param bool $isAnalyse statement contains PROCEDURE ANALYSE + * @param int|string $numRows total no. of rows returned by SQL query + * @param float $queryTime time taken for execute the SQL query + * @param string $textDirection text direction + * @param bool $isMaintenance statement contains a maintenance command + * @param bool $isExplain statement contains EXPLAIN + * @param bool $isShow statement contains SHOW + * @param bool $printView print view was requested + * @param bool $editable whether the results set is editable + * @param bool $isBrowseDistinct whether browsing distinct values * @psalm-param int|numeric-string $unlimNumRows * @psalm-param int|numeric-string $numRows */ @@ -373,7 +364,6 @@ class Results bool $isMaintenance, bool $isExplain, bool $isShow, - array|null $showTable, bool $printView, bool $editable, bool $isBrowseDistinct, @@ -390,7 +380,6 @@ class Results $this->isMaintenance = $isMaintenance; $this->isExplain = $isExplain; $this->isShow = $isShow; - $this->showTable = $showTable; $this->printView = $printView; $this->editable = $editable; $this->isBrowseDistinct = $isBrowseDistinct; @@ -631,7 +620,6 @@ class Results * * @param int $posNext the offset for the "next" page * @param int $posPrevious the offset for the "previous" page - * @param bool $isInnodb whether its InnoDB or not * @param mixed[] $sortByKeyData the sort by key dialog * * @return mixed[] @@ -639,7 +627,6 @@ class Results private function getTableNavigation( int $posNext, int $posPrevious, - bool $isInnodb, array $sortByKeyData, ): array { $isShowingAll = $_SESSION['tmpval']['max_rows'] === self::ALL_ROWS; @@ -665,7 +652,6 @@ class Results : 'false') . ';"'; $config = Config::getInstance(); - $hasRealEndInput = $isInnodb && $this->unlimNumRows > $config->settings['MaxExactCount']; $posLast = 0; if (is_numeric($_SESSION['tmpval']['max_rows'])) { $posLast = @((int) ceil( @@ -697,7 +683,6 @@ class Results 'pos_last' => $posLast, 'is_last_page' => $isLastPage, 'is_last_page_known' => $this->unlimNumRows !== false, - 'has_real_end_input' => $hasRealEndInput, 'onsubmit' => $onsubmit, ]; } @@ -3174,24 +3159,8 @@ class Results $statement = null; } - /** - * @todo move this to a central place - * @todo for other future table types - */ - $isInnodb = (isset($this->showTable['Type']) - && $this->showTable['Type'] === self::TABLE_TYPE_INNO_DB); - - if ($isInnodb && Sql::isJustBrowsing($statementInfo, true)) { - $preCount = '~'; - $afterCount = Generator::showHint( - Sanitize::convertBBCode( - __('May be approximate. See [doc@faq3-11]FAQ 3.11[/doc].'), - ), - ); - } else { - $preCount = ''; - $afterCount = ''; - } + $preCount = ''; + $afterCount = ''; // 1. ----- Prepares the work ----- @@ -3286,7 +3255,7 @@ class Results $navigation = []; if ($displayParts->hasNavigationBar && $statement !== null && empty($statement->limit)) { - $navigation = $this->getTableNavigation($posNext, $posPrev, $isInnodb, $sortByKeyData); + $navigation = $this->getTableNavigation($posNext, $posPrev, $sortByKeyData); } // 2b ----- Get field references from Database ----- diff --git a/src/Sql.php b/src/Sql.php index 70d8b26bb5..9d9cf79c49 100644 --- a/src/Sql.php +++ b/src/Sql.php @@ -36,7 +36,6 @@ use function count; use function defined; use function htmlspecialchars; use function in_array; -use function is_array; use function session_start; use function session_write_close; use function sprintf; @@ -979,7 +978,6 @@ class Sql false, 0, $numRows, - null, $result, $statementInfo, true, @@ -1063,7 +1061,6 @@ class Sql * @param bool $editable whether the result table is editable or not * @param int|string $unlimNumRows unlimited number of rows * @param int|string $numRows number of rows - * @param mixed[]|null $showTable table definitions * @param ResultInterface $result result of the executed query * @param bool $isLimitedDisplay Show only limited operations or not * @psalm-param int|numeric-string $unlimNumRows @@ -1075,7 +1072,6 @@ class Sql bool $editable, int|string $unlimNumRows, int|string $numRows, - array|null $showTable, ResultInterface $result, StatementInfo $statementInfo, bool $isLimitedDisplay = false, @@ -1088,7 +1084,6 @@ class Sql $result, $displayResultsObject, $statementInfo, - $showTable, $printView, $editable, $isBrowseDistinct, @@ -1110,7 +1105,6 @@ class Sql $statementInfo->isMaint, $statementInfo->isExplain, $statementInfo->isShow, - $showTable, $printView, $editable, $isBrowseDistinct, @@ -1119,12 +1113,10 @@ class Sql return $displayResultsObject->getTable($result, $displayParts, $statementInfo, $isLimitedDisplay); } - /** @param mixed[]|null $showTable table definitions */ private function getHtmlForStoredProcedureResults( ResultInterface $result, DisplayResults $displayResultsObject, StatementInfo $statementInfo, - array|null $showTable, bool $printView, bool $editable, bool $isBrowseDistinct, @@ -1149,7 +1141,6 @@ class Sql $statementInfo->isMaint, $statementInfo->isExplain, $statementInfo->isShow, - $showTable, $printView, $editable, $isBrowseDistinct, @@ -1287,8 +1278,6 @@ class Sql string $sqlQuery, string|null $completeQuery, ): string { - $GLOBALS['showtable'] ??= null; - // If we are retrieving the full value of a truncated field or the original // value of a transformed field, show it here if (isset($_POST['grid_edit']) && $_POST['grid_edit'] == true) { @@ -1299,11 +1288,6 @@ class Sql // Gets the list of fields properties $fieldsMeta = $this->dbi->getFieldsMeta($result); - // Should be initialized these parameters before parsing - if (! is_array($GLOBALS['showtable'])) { - $GLOBALS['showtable'] = null; - } - $response = ResponseRenderer::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); @@ -1407,7 +1391,6 @@ class Sql $editable, $unlimNumRows, $numRows, - $GLOBALS['showtable'], $result, $statementInfo, ); diff --git a/src/Table/Table.php b/src/Table/Table.php index fa29abe48d..c2baae5859 100644 --- a/src/Table/Table.php +++ b/src/Table/Table.php @@ -375,11 +375,11 @@ class Table implements Stringable * * @return int Return no of rows info if it is not null for the selected table or return 0. */ - public function getNumRows(): int + public function getNumRows(string $showTableName): int { $tableNumRowInfo = $this->getStatusInfo('TABLE_ROWS', false, true); if ($tableNumRowInfo === false) { - $tableNumRowInfo = $this->dbi->getTable($this->dbName, $GLOBALS['showtable']['Name']) + $tableNumRowInfo = $this->dbi->getTable($this->dbName, $showTableName) ->countRecords(true); } diff --git a/tests/classes/Controllers/Table/DeleteRowsControllerTest.php b/tests/classes/Controllers/Table/DeleteRowsControllerTest.php index 897105550b..e9d08fca0c 100644 --- a/tests/classes/Controllers/Table/DeleteRowsControllerTest.php +++ b/tests/classes/Controllers/Table/DeleteRowsControllerTest.php @@ -19,7 +19,6 @@ class DeleteRowsControllerTest extends AbstractTestCase public function testDeleteRowsController(): void { $GLOBALS['goto'] = null; - $GLOBALS['showtable'] = null; $GLOBALS['db'] = 'test_db'; $GLOBALS['table'] = 'test_table'; $GLOBALS['urlParams'] = []; diff --git a/tests/classes/Controllers/Table/ReplaceControllerTest.php b/tests/classes/Controllers/Table/ReplaceControllerTest.php index 2475215b72..d08c9ef1d5 100644 --- a/tests/classes/Controllers/Table/ReplaceControllerTest.php +++ b/tests/classes/Controllers/Table/ReplaceControllerTest.php @@ -45,7 +45,6 @@ class ReplaceControllerTest extends AbstractTestCase $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; $GLOBALS['server'] = 1; - $GLOBALS['showtable'] = null; $GLOBALS['db'] = 'my_db'; $GLOBALS['table'] = 'test_tbl'; diff --git a/tests/classes/Display/ResultsTest.php b/tests/classes/Display/ResultsTest.php index 71f552fd4d..4dab842a6d 100644 --- a/tests/classes/Display/ResultsTest.php +++ b/tests/classes/Display/ResultsTest.php @@ -1170,7 +1170,6 @@ class ResultsTest extends AbstractTestCase $statementInfo->isMaint, $statementInfo->isExplain, $statementInfo->isShow, - null, false, true, false, @@ -1463,7 +1462,6 @@ class ResultsTest extends AbstractTestCase $statementInfo->isMaint, $statementInfo->isExplain, $statementInfo->isShow, - null, false, true, true, diff --git a/tests/classes/SqlTest.php b/tests/classes/SqlTest.php index 4362b2fb29..c1933ff05f 100644 --- a/tests/classes/SqlTest.php +++ b/tests/classes/SqlTest.php @@ -61,7 +61,6 @@ class SqlTest extends AbstractTestCase $config->settings['Confirm'] = true; $config->settings['LoginCookieValidity'] = 1440; $config->settings['enable_drag_drop_import'] = true; - $GLOBALS['showtable'] = null; $relation = new Relation($this->dbi); $this->sql = new Sql( From 4ea2b81612c2fc62353833ce5eed1c891d9b026a Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 15 Dec 2023 20:12:50 +0100 Subject: [PATCH 3/6] Remove $GLOBALS['is_gotofile'] Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 5 ----- psalm-baseline.xml | 2 -- src/Controllers/Sql/SqlController.php | 7 +++---- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b65cb4eb0c..b07f58b3b1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5280,11 +5280,6 @@ parameters: count: 1 path: src/Controllers/Sql/SqlController.php - - - message: "#^Parameter \\#2 \\$isGotoFile of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndSendQueryResponse\\(\\) expects bool, mixed given\\.$#" - count: 1 - path: src/Controllers/Sql/SqlController.php - - message: "#^Parameter \\#2 \\$signature of static method PhpMyAdmin\\\\Core\\:\\:checkSqlQuerySignature\\(\\) expects string, mixed given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b9e09ac572..972f08ae4d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3207,7 +3207,6 @@ - @@ -3232,7 +3231,6 @@ - diff --git a/src/Controllers/Sql/SqlController.php b/src/Controllers/Sql/SqlController.php index da793d164f..6e4b09148d 100644 --- a/src/Controllers/Sql/SqlController.php +++ b/src/Controllers/Sql/SqlController.php @@ -53,7 +53,6 @@ class SqlController extends AbstractController $GLOBALS['message_to_show'] ??= null; $GLOBALS['disp_message'] ??= null; $GLOBALS['complete_query'] ??= null; - $GLOBALS['is_gotofile'] ??= null; $GLOBALS['back'] ??= null; $GLOBALS['table_from_sql'] ??= null; @@ -80,7 +79,7 @@ class SqlController extends AbstractController /** * Defines the url to return to in case of error in a sql statement */ - $GLOBALS['is_gotofile'] = true; + $isGotofile = true; $config = Config::getInstance(); if (empty($GLOBALS['goto'])) { if (empty($GLOBALS['table'])) { @@ -186,7 +185,7 @@ class SqlController extends AbstractController * Sets or modifies the $goto variable if required */ if ($GLOBALS['goto'] === Url::getFromRoute('/sql')) { - $GLOBALS['is_gotofile'] = false; + $isGotofile = false; $GLOBALS['goto'] = Url::getFromRoute('/sql', [ 'db' => $GLOBALS['db'], 'table' => $GLOBALS['table'], @@ -196,7 +195,7 @@ class SqlController extends AbstractController $this->response->addHTML($this->sql->executeQueryAndSendQueryResponse( $statementInfo, - $GLOBALS['is_gotofile'], + $isGotofile, $GLOBALS['db'], $GLOBALS['table'], $GLOBALS['import_text'] ?? null, From 7f180163dd92ee7ce5fde27278e712513434fd5d Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 15 Dec 2023 20:24:21 +0100 Subject: [PATCH 4/6] Remove $GLOBALS['table_from_sql'] Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 2 +- psalm-baseline.xml | 2 -- src/Controllers/Sql/SqlController.php | 10 +++------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b07f58b3b1..db786c5e93 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5212,7 +5212,7 @@ parameters: - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" - count: 5 + count: 4 path: src/Controllers/Sql/SqlController.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 972f08ae4d..ca234ddd3f 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3208,7 +3208,6 @@ - @@ -3233,7 +3232,6 @@ - $bkmAllUsers $sqlQuery diff --git a/src/Controllers/Sql/SqlController.php b/src/Controllers/Sql/SqlController.php index 6e4b09148d..88a474d6c9 100644 --- a/src/Controllers/Sql/SqlController.php +++ b/src/Controllers/Sql/SqlController.php @@ -54,7 +54,6 @@ class SqlController extends AbstractController $GLOBALS['disp_message'] ??= null; $GLOBALS['complete_query'] ??= null; $GLOBALS['back'] ??= null; - $GLOBALS['table_from_sql'] ??= null; $this->checkUserPrivileges->getPrivileges(); @@ -139,13 +138,10 @@ class SqlController extends AbstractController /** * Parse and analyze the query */ - [$statementInfo, $GLOBALS['db'], $GLOBALS['table_from_sql']] = ParseAnalyze::sqlQuery( - $GLOBALS['sql_query'], - $GLOBALS['db'], - ); + [$statementInfo, $GLOBALS['db'], $tableFromSql] = ParseAnalyze::sqlQuery($GLOBALS['sql_query'], $GLOBALS['db']); - if ($GLOBALS['table'] != $GLOBALS['table_from_sql'] && ! empty($GLOBALS['table_from_sql'])) { - $GLOBALS['table'] = $GLOBALS['table_from_sql']; + if ($GLOBALS['table'] != $tableFromSql && $tableFromSql !== '') { + $GLOBALS['table'] = $tableFromSql; } /** From 0ada2f471a1cae38b9dda3fdfb199f30956b96e9 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 16 Dec 2023 02:05:47 +0100 Subject: [PATCH 5/6] Remove old comment Signed-off-by: Kamil Tekiela --- src/Sql.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Sql.php b/src/Sql.php index 9d9cf79c49..3b3d978a9d 100644 --- a/src/Sql.php +++ b/src/Sql.php @@ -642,9 +642,6 @@ class Sql // and no WHERE clause (or just 'WHERE 1 '), // we do a quick count (which uses MaxExactCount) because // SQL_CALC_FOUND_ROWS is not quick on large InnoDB tables - - // However, do not count again if we did it previously - // due to $find_real_end == true if ($justBrowsing) { // Get row count (is approximate for InnoDB) $unlimNumRows = $this->dbi->getTable($db, $table)->countRecords(); From 46aebebe1bd6f57684b0a79870b7dcdc5268d2bb Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 16 Dec 2023 02:25:26 +0100 Subject: [PATCH 6/6] Remove JS confirmation Signed-off-by: Kamil Tekiela --- resources/js/src/database/structure.ts | 21 ------------------- .../JavaScriptMessagesController.php | 1 - 2 files changed, 22 deletions(-) diff --git a/resources/js/src/database/structure.ts b/resources/js/src/database/structure.ts index 6ab36133bd..c8d8dcf600 100644 --- a/resources/js/src/database/structure.ts +++ b/resources/js/src/database/structure.ts @@ -31,7 +31,6 @@ import { escapeHtml } from '../modules/functions/escape.ts'; AJAX.registerTeardown('database/structure.js', function () { $(document).off('click', 'a.truncate_table_anchor.ajax'); $(document).off('click', 'a.drop_table_anchor.ajax'); - $(document).off('click', '#real_end_input'); $(document).off('click', 'a.favorite_table_anchor.ajax'); $('a.real_row_count').off('click'); $('a.row_count_sum').off('click'); @@ -419,26 +418,6 @@ AJAX.registerOnload('database/structure.js', function () { }, Functions.loadForeignKeyCheckbox); }); // end of Drop Table Ajax action - // Calculate Real End for InnoDB - /** - * Ajax Event handler for calculating the real end for a InnoDB table - * - */ - $(document).on('click', '#real_end_input', function (event) { - event.preventDefault(); - - /** - * @var question String containing the question to be asked for confirmation - */ - var question = window.Messages.strOperationTakesLongTime; - - $(this).confirm(question, '', function () { - return true; - }); - - return false; - }); // end Calculate Real End for InnoDB - // Add tooltip to favorite icons. $('.favorite_table_anchor').each(function () { tooltip($(this), 'a', $(this).attr('title')); diff --git a/src/Controllers/JavaScriptMessagesController.php b/src/Controllers/JavaScriptMessagesController.php index 86050b9cff..dd5c0fcff2 100644 --- a/src/Controllers/JavaScriptMessagesController.php +++ b/src/Controllers/JavaScriptMessagesController.php @@ -65,7 +65,6 @@ final class JavaScriptMessagesController 'strDeletingTrackingData' => __('Deleting tracking data'), 'strDroppingPrimaryKeyIndex' => __('Dropping Primary Key/Index'), 'strDroppingForeignKey' => __('Dropping Foreign key.'), - 'strOperationTakesLongTime' => __('This operation could take a long time. Proceed anyway?'), 'strDropUserGroupWarning' => __('Do you really want to delete user group "%s"?'), 'strConfirmNavigation' => __('You have unsaved changes; are you sure you want to leave this page?'), 'strConfirmRowChange' => __(