Skip to content

Commit 6f1a3f4

Browse files
Merge pull request #18715 from kamil-tekiela/fix-real-count
Fix AJAX real-row-count
2 parents 6e695df + dba0086 commit 6f1a3f4

5 files changed

Lines changed: 15 additions & 11 deletions

File tree

js/src/database/structure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ DatabaseStructure.fetchRealRowCount = function ($target) {
158158
if (response.success) {
159159
// If to update all row counts for a DB.
160160
if (response.real_row_count_all) {
161-
$.each(JSON.parse(response.real_row_count_all),
161+
$.each(response.real_row_count_all,
162162
function (index, table) {
163163
// Update each table row count.
164164
$('table.data td[data-table*="' + table.table + '"]')

libraries/classes/Controllers/Database/Structure/RealRowCountController.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
use PhpMyAdmin\Url;
1212
use PhpMyAdmin\Util;
1313

14-
use function json_encode;
15-
1614
/**
1715
* Handles request for real row count on database level view page.
1816
*/
@@ -70,10 +68,10 @@ public function __invoke(): void
7068
->getRealRowCountTable();
7169
$realRowCountAll[] = [
7270
'table' => $table['TABLE_NAME'],
73-
'row_count' => $rowCount,
71+
'row_count' => Util::formatNumber($rowCount, 0),
7472
];
7573
}
7674

77-
$this->response->addJSON(['real_row_count_all' => json_encode($realRowCountAll)]);
75+
$this->response->addJSON(['real_row_count_all' => $realRowCountAll]);
7876
}
7977
}

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,11 @@ parameters:
10751075
count: 1
10761076
path: libraries/classes/Controllers/Database/Structure/FavoriteTableController.php
10771077

1078+
-
1079+
message: "#^Parameter \\#1 \\$value of static method PhpMyAdmin\\\\Util\\:\\:formatNumber\\(\\) expects float\\|int\\|string, int\\|null given\\.$#"
1080+
count: 1
1081+
path: libraries/classes/Controllers/Database/Structure/RealRowCountController.php
1082+
10781083
-
10791084
message: "#^Cannot use array destructuring on array\\|null\\.$#"
10801085
count: 4

psalm-baseline.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,9 @@
17261726
<PossiblyInvalidCast occurrences="1">
17271727
<code>$parameters['table']</code>
17281728
</PossiblyInvalidCast>
1729+
<PossiblyNullArgument occurrences="1">
1730+
<code>$rowCount</code>
1731+
</PossiblyNullArgument>
17291732
</file>
17301733
<file src="libraries/classes/Controllers/Database/Structure/ReplacePrefixController.php">
17311734
<MixedArgument occurrences="1">

test/classes/Controllers/Database/Structure/RealRowCountControllerTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use PhpMyAdmin\Tests\AbstractTestCase;
1010
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseStub;
1111

12-
use function json_encode;
13-
1412
/**
1513
* @covers \PhpMyAdmin\Controllers\Database\Structure\RealRowCountController
1614
*/
@@ -41,10 +39,10 @@ public function testRealRowCount(): void
4139

4240
$json = $response->getJSONResult();
4341
$expected = [
44-
['table' => 'City', 'row_count' => 4079],
45-
['table' => 'Country', 'row_count' => 239],
46-
['table' => 'CountryLanguage', 'row_count' => 984],
42+
['table' => 'City', 'row_count' => '4,079'],
43+
['table' => 'Country', 'row_count' => '239'],
44+
['table' => 'CountryLanguage', 'row_count' => '984'],
4745
];
48-
$this->assertEquals(json_encode($expected), $json['real_row_count_all']);
46+
$this->assertEquals($expected, $json['real_row_count_all']);
4947
}
5048
}

0 commit comments

Comments
 (0)