diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 1a325dd3391d..7d0dba63edb9 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -133,6 +133,7 @@ class Results * unlim_num_rows: int|numeric-string|false, * fields_meta: FieldMetadata[], * is_count: bool|null, + * is_group: bool|null, * is_export: bool|null, * is_func: bool|null, * is_analyse: bool|null, @@ -178,6 +179,8 @@ class Results 'is_count' => null, + 'is_group' => null, + 'is_export' => null, 'is_func' => null, @@ -394,6 +397,7 @@ private function setDefaultTransformations(): void * any appended "LIMIT" clause programmatically * @param FieldMetadata[] $fieldsMeta meta information about fields * @param bool $isCount statement is SELECT COUNT + * @param bool $isGroup statement has GROUP BY * @param bool $isExport statement contains INTO OUTFILE * @param bool $isFunction statement contains a function like SUM() * @param bool $isAnalyse statement contains PROCEDURE ANALYSE @@ -415,6 +419,7 @@ public function setProperties( $unlimNumRows, array $fieldsMeta, $isCount, + $isGroup, $isExport, $isFunction, $isAnalyse, @@ -433,6 +438,7 @@ public function setProperties( $this->properties['unlim_num_rows'] = $unlimNumRows; $this->properties['fields_meta'] = $fieldsMeta; $this->properties['is_count'] = $isCount; + $this->properties['is_group'] = $isGroup; $this->properties['is_export'] = $isExport; $this->properties['is_func'] = $isFunction; $this->properties['is_analyse'] = $isAnalyse; @@ -466,6 +472,7 @@ private function setDisplayPartsForPrintView(array $displayParts) $displayParts['bkm_form'] = '0'; $displayParts['text_btn'] = '0'; $displayParts['pview_lnk'] = '0'; + $displayParts['query_stats'] = '1'; return $displayParts; } @@ -510,6 +517,7 @@ private function setDisplayPartsForShow(array $displayParts) $displayParts['bkm_form'] = '1'; $displayParts['text_btn'] = '1'; $displayParts['pview_lnk'] = '1'; + $displayParts['query_stats'] = '0'; return $displayParts; } @@ -531,6 +539,7 @@ private function setDisplayPartsForNonData(array $displayParts) $displayParts['sort_lnk'] = '0'; $displayParts['nav_bar'] = '0'; $displayParts['bkm_form'] = '1'; + $displayParts['query_stats'] = '0'; if ($this->properties['is_maint']) { $displayParts['text_btn'] = '1'; @@ -628,14 +637,13 @@ private function setDisplayPartsAndTotal(array $displayParts) $db = $this->properties['db']; $table = $this->properties['table']; $unlimNumRows = $this->properties['unlim_num_rows']; - $numRows = $this->properties['num_rows']; $printView = $this->properties['printview']; // 2. Updates the display parts if ($printView == '1') { $displayParts = $this->setDisplayPartsForPrintView($displayParts); } elseif ( - $this->properties['is_count'] || $this->properties['is_analyse'] + $this->properties['is_analyse'] || $this->properties['is_maint'] || $this->properties['is_explain'] ) { $displayParts = $this->setDisplayPartsForNonData($displayParts); @@ -658,9 +666,9 @@ private function setDisplayPartsAndTotal(array $displayParts) // if for COUNT query, number of rows returned more than 1 // (may be being used GROUP BY) - if ($this->properties['is_count'] && $numRows > 1) { - $displayParts['nav_bar'] = '1'; - $displayParts['sort_lnk'] = '1'; + if ($this->properties['is_count'] && ! $this->properties['is_group']) { + $displayParts['nav_bar'] = '0'; + $displayParts['sort_lnk'] = '0'; } // 4. If navigation bar or sorting fields names URLs should be @@ -3642,7 +3650,7 @@ public function getTable( // 1.2 Defines offsets for the next and previous pages $posNext = 0; $posPrev = 0; - if ($displayParts['nav_bar'] == '1') { + if ($displayParts['nav_bar'] == '1' || $displayParts['query_stats'] === '1') { [$posNext, $posPrev] = $this->getOffsets(); } @@ -3675,7 +3683,7 @@ public function getTable( // 2.1 Prepares a messages with position information $sqlQueryMessage = ''; - if ($displayParts['nav_bar'] == '1') { + if ($displayParts['query_stats'] == '1') { $message = $this->setMessageInformation( $sortedColumnMessage, $analyzedSqlResults, diff --git a/libraries/classes/Sql.php b/libraries/classes/Sql.php index 60bf5a9dc178..67d5bcbc9898 100644 --- a/libraries/classes/Sql.php +++ b/libraries/classes/Sql.php @@ -1078,6 +1078,7 @@ private function getQueryResponseForNoResultsReturned( 'bkm_form' => '1', 'text_btn' => '1', 'pview_lnk' => '1', + 'query_stats' => '1', ]; $sqlQueryResultsTable = $this->getHtmlForSqlQueryResultsTable( @@ -1222,6 +1223,7 @@ private function getHtmlForSqlQueryResultsTable( $numRows, $fieldsMeta, $analyzedSqlResults['is_count'], + $analyzedSqlResults['is_group'], $analyzedSqlResults['is_export'], $analyzedSqlResults['is_func'], $analyzedSqlResults['is_analyse'], @@ -1246,6 +1248,7 @@ private function getHtmlForSqlQueryResultsTable( 'bkm_form' => '1', 'text_btn' => '1', 'pview_lnk' => '1', + 'query_stats' => '1', ]; $tableHtml .= $displayResultsObject->getTable( @@ -1270,6 +1273,7 @@ private function getHtmlForSqlQueryResultsTable( $unlimNumRows, $fieldsMeta, $analyzedSqlResults['is_count'], + $analyzedSqlResults['is_group'], $analyzedSqlResults['is_export'], $analyzedSqlResults['is_func'], $analyzedSqlResults['is_analyse'], @@ -1477,6 +1481,7 @@ private function getQueryResponseForResultsReturned( 'bkm_form' => '1', 'text_btn' => '0', 'pview_lnk' => '1', + 'query_stats' => '1', ]; if (! $editable) { @@ -1488,6 +1493,7 @@ private function getQueryResponseForResultsReturned( 'bkm_form' => '1', 'text_btn' => '1', 'pview_lnk' => '1', + 'query_stats' => '1', ]; } @@ -1500,6 +1506,7 @@ private function getQueryResponseForResultsReturned( 'bkm_form' => '0', 'text_btn' => '0', 'pview_lnk' => '0', + 'query_stats' => '0', ]; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e8995a03e724..f6942c7b6cbd 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -6066,7 +6066,7 @@ $sortExpression $urlParams - + $_SESSION['tmpval']['display_binary'] $_SESSION['tmpval']['display_binary'] $_SESSION['tmpval']['display_binary'] @@ -6112,7 +6112,8 @@ $displayParams['data'][$rowNumber] $displayParts['nav_bar'] $displayParts['nav_bar'] - $displayParts['nav_bar'] + $displayParts['query_stats'] + $displayParts['query_stats'] $displayParts['sort_lnk'] $oneKey['index_list'] $oneKey['ref_db_name'] diff --git a/test/classes/Display/ResultsTest.php b/test/classes/Display/ResultsTest.php index db956a1e4860..200e1f0e4f27 100644 --- a/test/classes/Display/ResultsTest.php +++ b/test/classes/Display/ResultsTest.php @@ -1416,6 +1416,7 @@ public function testGetTable(): void 3, $fieldsMeta, $analyzedSqlResults['is_count'], + $analyzedSqlResults['is_group'], $analyzedSqlResults['is_export'], $analyzedSqlResults['is_func'], $analyzedSqlResults['is_analyse'], @@ -1454,6 +1455,7 @@ public function testGetTable(): void 'bkm_form' => '1', 'text_btn' => '0', 'pview_lnk' => '1', + 'query_stats' => '1', ]; $this->assertNotFalse($dtResult); $actual = $object->getTable($dtResult, $displayParts, $analyzedSqlResults);