Merge pull request #18952 from kamil-tekiela/Fix-#18949
Implement natural sort for items in the navigation section Fixes #18949
This commit is contained in:
commit
be6685c344
@ -12,9 +12,10 @@ use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
use function array_slice;
|
||||
use function in_array;
|
||||
use function intval;
|
||||
use function substr;
|
||||
use function usort;
|
||||
|
||||
/**
|
||||
* Represents a database node in the navigation tree
|
||||
@ -439,7 +440,6 @@ class NodeDatabase extends Node
|
||||
}
|
||||
|
||||
$query .= 'ORDER BY `TABLE_NAME` ASC ';
|
||||
$query .= 'LIMIT ' . $pos . ', ' . $maxItems;
|
||||
$retval = $dbi->fetchResult($query);
|
||||
} else {
|
||||
$query = ' SHOW FULL TABLES FROM ';
|
||||
@ -453,21 +453,15 @@ class NodeDatabase extends Node
|
||||
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
if ($handle->seek($pos)) {
|
||||
while ($arr = $handle->fetchRow()) {
|
||||
if ($count >= $maxItems) {
|
||||
break;
|
||||
}
|
||||
|
||||
$retval[] = $arr[0];
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$retval = $handle->fetchAllColumn();
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
if ($GLOBALS['cfg']['NaturalOrder']) {
|
||||
usort($retval, 'strnatcasecmp');
|
||||
}
|
||||
|
||||
return array_slice($retval, $pos, $maxItems);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -526,7 +520,6 @@ class NodeDatabase extends Node
|
||||
}
|
||||
|
||||
$query .= 'ORDER BY `ROUTINE_NAME` ASC ';
|
||||
$query .= 'LIMIT ' . intval($pos) . ', ' . $maxItems;
|
||||
$retval = $dbi->fetchResult($query);
|
||||
} else {
|
||||
$escdDb = $dbi->escapeString($db);
|
||||
@ -539,21 +532,17 @@ class NodeDatabase extends Node
|
||||
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
if ($handle->seek($pos)) {
|
||||
while ($arr = $handle->fetchAssoc()) {
|
||||
if ($count >= $maxItems) {
|
||||
break;
|
||||
}
|
||||
|
||||
$retval[] = $arr['Name'];
|
||||
$count++;
|
||||
}
|
||||
while ($arr = $handle->fetchAssoc()) {
|
||||
$retval[] = $arr['Name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
if ($GLOBALS['cfg']['NaturalOrder']) {
|
||||
usort($retval, 'strnatcasecmp');
|
||||
}
|
||||
|
||||
return array_slice($retval, $pos, $maxItems);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -610,7 +599,6 @@ class NodeDatabase extends Node
|
||||
}
|
||||
|
||||
$query .= 'ORDER BY `EVENT_NAME` ASC ';
|
||||
$query .= 'LIMIT ' . intval($pos) . ', ' . $maxItems;
|
||||
$retval = $dbi->fetchResult($query);
|
||||
} else {
|
||||
$escdDb = Util::backquote($db);
|
||||
@ -623,21 +611,17 @@ class NodeDatabase extends Node
|
||||
|
||||
$handle = $dbi->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
if ($handle->seek($pos)) {
|
||||
while ($arr = $handle->fetchAssoc()) {
|
||||
if ($count >= $maxItems) {
|
||||
break;
|
||||
}
|
||||
|
||||
$retval[] = $arr['Name'];
|
||||
$count++;
|
||||
}
|
||||
while ($arr = $handle->fetchAssoc()) {
|
||||
$retval[] = $arr['Name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
if ($GLOBALS['cfg']['NaturalOrder']) {
|
||||
usort($retval, 'strnatcasecmp');
|
||||
}
|
||||
|
||||
return array_slice($retval, $pos, $maxItems);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -8724,6 +8724,11 @@
|
||||
</PropertyNotSetInConstructor>
|
||||
</file>
|
||||
<file src="libraries/classes/Navigation/Nodes/NodeDatabase.php">
|
||||
<InvalidArgument occurrences="3">
|
||||
<code>usort($retval, 'strnatcasecmp')</code>
|
||||
<code>usort($retval, 'strnatcasecmp')</code>
|
||||
<code>usort($retval, 'strnatcasecmp')</code>
|
||||
</InvalidArgument>
|
||||
<InvalidReturnStatement occurrences="4">
|
||||
<code>$retval</code>
|
||||
<code>$retval</code>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user