diff options
author | Bartosz Dziewoński <matma.rex@gmail.com> | 2021-01-25 17:43:00 +0100 |
---|---|---|
committer | Bartosz Dziewoński <matma.rex@gmail.com> | 2021-12-24 01:09:47 +0000 |
commit | 534ec8a9c3df046fbc6d5f1ea4f6c9d06d4b6d03 (patch) | |
tree | 17f35af7c8ddfac39b9f12976e3a43d2237690e6 | |
parent | ae411974c9cf2daa7d77266af4a04cd37b9da7c6 (diff) |
Consistently order change tags
When tags are shown on history pages, recent changes, and so on,
they will now be shown in the same order as the result of
listDefinedTags(), rather than by their ctd_id (corresponding
to the order in which they were first used on a given wiki).
This allows extensions using the ListDefinedTags hook to have their
tags displayed in a specific order consistently on every wiki.
Bug: T272900
Change-Id: I4c85cb840c1fac52f5ab268beee9e6a7fd20b91e
-rw-r--r-- | includes/changetags/ChangeTags.php | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 68be1ab1a8a5..c49743147144 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -202,6 +202,11 @@ class ChangeTags { $classes = []; $tags = explode( ',', $tags ); + $order = array_flip( self::listDefinedTags() ); + usort( $tags, static function ( $a, $b ) use ( $order ) { + return ( $order[ $a ] ?? INF ) <=> ( $order[ $b ] ?? INF ); + } ); + $displayTags = []; foreach ( $tags as $tag ) { if ( !$tag ) { |