Visitar URL original
Merge branch 'QA_5_2' · phpmyadmin/phpmyadmin@bdc08e5 · GitHub
Skip to content

Commit bdc08e5

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2 parents 92a1a4d + be6685c commit bdc08e5

3 files changed

Lines changed: 60 additions & 40 deletions

File tree

‎phpstan-baseline.neon‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9890,6 +9890,16 @@ parameters:
98909890
count: 1
98919891
path: src/Navigation/Nodes/NodeDatabase.php
98929892

9893+
-
9894+
message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(mixed, mixed\\)\\: int, 'strnatcasecmp' given\\.$#"
9895+
count: 3
9896+
path: src/Navigation/Nodes/NodeDatabase.php
9897+
9898+
-
9899+
message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(string\\|null, string\\|null\\)\\: int, 'strnatcasecmp' given\\.$#"
9900+
count: 3
9901+
path: src/Navigation/Nodes/NodeDatabase.php
9902+
98939903
-
98949904
message: "#^Cannot access property \\$realName on PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\|false\\.$#"
98959905
count: 1

‎psalm-baseline.xml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7527,6 +7527,11 @@
75277527
<code>DatabaseInterface::getInstance()</code>
75287528
<code>DatabaseInterface::getInstance()</code>
75297529
</DeprecatedMethod>
7530+
<InvalidArgument>
7531+
<code><![CDATA[usort($retval, 'strnatcasecmp')]]></code>
7532+
<code><![CDATA[usort($retval, 'strnatcasecmp')]]></code>
7533+
<code><![CDATA[usort($retval, 'strnatcasecmp')]]></code>
7534+
</InvalidArgument>
75307535
<InvalidReturnStatement>
75317536
<code><![CDATA[$dbi->queryAndGetNumRows($query)]]></code>
75327537
<code><![CDATA[$dbi->queryAndGetNumRows($query)]]></code>
@@ -7539,6 +7544,11 @@
75397544
<code>int</code>
75407545
<code>int</code>
75417546
</InvalidReturnType>
7547+
<MixedArgumentTypeCoercion>
7548+
<code><![CDATA[usort($retval, 'strnatcasecmp')]]></code>
7549+
<code><![CDATA[usort($retval, 'strnatcasecmp')]]></code>
7550+
<code><![CDATA[usort($retval, 'strnatcasecmp')]]></code>
7551+
</MixedArgumentTypeCoercion>
75427552
</file>
75437553
<file src="src/Navigation/Nodes/NodeDatabaseChild.php">
75447554
<PossiblyInvalidPropertyFetch>

‎src/Navigation/Nodes/NodeDatabase.php‎

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
use PhpMyAdmin\Util;
1919

2020
use function __;
21+
use function array_slice;
2122
use function in_array;
2223
use function substr;
24+
use function usort;
2325

2426
/**
2527
* Represents a database node in the navigation tree
@@ -350,9 +352,13 @@ private function getTablesOrViews(string $which, int $pos, string $searchClause)
350352
}
351353

352354
$query .= 'ORDER BY `TABLE_NAME` ASC ';
353-
$query .= 'LIMIT ' . $pos . ', ' . $maxItems;
355+
$retval = $dbi->fetchResult($query);
354356

355-
return $dbi->fetchResult($query);
357+
if ($config->settings['NaturalOrder']) {
358+
usort($retval, 'strnatcasecmp');
359+
}
360+
361+
return array_slice($retval, $pos, $maxItems);
356362
}
357363

358364
$query = ' SHOW FULL TABLES FROM ';
@@ -368,20 +374,14 @@ private function getTablesOrViews(string $which, int $pos, string $searchClause)
368374
$retval = [];
369375
$handle = $dbi->tryQuery($query);
370376
if ($handle !== false) {
371-
$count = 0;
372-
if ($handle->seek($pos)) {
373-
while ($arr = $handle->fetchRow()) {
374-
if ($count >= $maxItems) {
375-
break;
376-
}
377-
378-
$retval[] = $arr[0];
379-
$count++;
380-
}
381-
}
377+
$retval = $handle->fetchAllColumn();
382378
}
383379

384-
return $retval;
380+
if ($config->settings['NaturalOrder']) {
381+
usort($retval, 'strnatcasecmp');
382+
}
383+
384+
return array_slice($retval, $pos, $maxItems);
385385
}
386386

387387
/**
@@ -438,9 +438,13 @@ private function getRoutines(string $routineType, int $pos, string $searchClause
438438
}
439439

440440
$query .= 'ORDER BY `ROUTINE_NAME` ASC ';
441-
$query .= 'LIMIT ' . $pos . ', ' . $maxItems;
441+
$retval = $dbi->fetchResult($query);
442442

443-
return $dbi->fetchResult($query);
443+
if ($config->settings['NaturalOrder']) {
444+
usort($retval, 'strnatcasecmp');
445+
}
446+
447+
return array_slice($retval, $pos, $maxItems);
444448
}
445449

446450
$query = 'SHOW ' . $routineType . ' STATUS WHERE `Db`=' . $dbi->quoteString($this->realName) . ' ';
@@ -454,20 +458,16 @@ private function getRoutines(string $routineType, int $pos, string $searchClause
454458
$retval = [];
455459
$handle = $dbi->tryQuery($query);
456460
if ($handle !== false) {
457-
$count = 0;
458-
if ($handle->seek($pos)) {
459-
while ($arr = $handle->fetchAssoc()) {
460-
if ($count >= $maxItems) {
461-
break;
462-
}
463-
464-
$retval[] = $arr['Name'];
465-
$count++;
466-
}
461+
while ($arr = $handle->fetchAssoc()) {
462+
$retval[] = $arr['Name'];
467463
}
468464
}
469465

470-
return $retval;
466+
if ($config->settings['NaturalOrder']) {
467+
usort($retval, 'strnatcasecmp');
468+
}
469+
470+
return array_slice($retval, $pos, $maxItems);
471471
}
472472

473473
/**
@@ -522,9 +522,13 @@ private function getEvents(int $pos, string $searchClause): array
522522
}
523523

524524
$query .= 'ORDER BY `EVENT_NAME` ASC ';
525-
$query .= 'LIMIT ' . $pos . ', ' . $maxItems;
525+
$retval = $dbi->fetchResult($query);
526+
527+
if ($config->settings['NaturalOrder']) {
528+
usort($retval, 'strnatcasecmp');
529+
}
526530

527-
return $dbi->fetchResult($query);
531+
return array_slice($retval, $pos, $maxItems);
528532
}
529533

530534
$query = 'SHOW EVENTS FROM ' . Util::backquote($this->realName) . ' ';
@@ -538,20 +542,16 @@ private function getEvents(int $pos, string $searchClause): array
538542
$retval = [];
539543
$handle = $dbi->tryQuery($query);
540544
if ($handle !== false) {
541-
$count = 0;
542-
if ($handle->seek($pos)) {
543-
while ($arr = $handle->fetchAssoc()) {
544-
if ($count >= $maxItems) {
545-
break;
546-
}
547-
548-
$retval[] = $arr['Name'];
549-
$count++;
550-
}
545+
while ($arr = $handle->fetchAssoc()) {
546+
$retval[] = $arr['Name'];
551547
}
552548
}
553549

554-
return $retval;
550+
if ($config->settings['NaturalOrder']) {
551+
usort($retval, 'strnatcasecmp');
552+
}
553+
554+
return array_slice($retval, $pos, $maxItems);
555555
}
556556

557557
/**

0 commit comments

Comments
 (0)