Merge #19331 - Fix #17182 - FK Relationship View constraint name natural ordering

Pull-request: #19331
Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2026-01-17 14:32:52 +01:00
commit de85bcb05c
No known key found for this signature in database
GPG Key ID: 70684F4717D49A31
2 changed files with 12 additions and 3 deletions

View File

@ -3612,9 +3612,9 @@ Various display setting
:type: boolean
:default: true
Sorts database and table names according to natural order (for
example, t1, t2, t10). Currently implemented in the navigation panel
and in Database view, for the table list.
Sorts database, table names and foreign key constaint according to natural order (for
example, t1, t2, t10). Currently implemented in the navigation panel,
in Database view for the table list and Relation view while listing Foreign key constraints.
.. config:option:: $cfg['InitialSlidersState']

View File

@ -19,6 +19,7 @@ use PhpMyAdmin\Indexes\Index;
use PhpMyAdmin\MessageType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Routing\Route;
use PhpMyAdmin\SqlParser\Utils\ForeignKey as ForeignKeyObject;
use PhpMyAdmin\Table\Table;
use PhpMyAdmin\Template;
use PhpMyAdmin\UrlParams;
@ -28,6 +29,7 @@ use function __;
use function array_keys;
use function md5;
use function strnatcasecmp;
use function strnatcmp;
use function uksort;
use function usort;
@ -179,6 +181,13 @@ final readonly class RelationController implements InvocableController
if ($this->config->settings['NaturalOrder']) {
uksort($columnArray, strnatcasecmp(...));
usort(
$relationsForeign,
static fn (ForeignKeyObject $before, ForeignKeyObject $after) => strnatcmp(
$before->constraint ?? '',
$after->constraint ?? '',
),
);
}
$foreignKeyRow = '';