fix(hooks): 🐛 add missing article page icon on talk pages

Fixes: #867
This commit is contained in:
alistair3149 2024-06-06 14:43:34 -04:00
parent f648c24a65
commit e372c4b733
No known key found for this signature in database
2 changed files with 8 additions and 2 deletions

View file

@ -277,9 +277,14 @@ class SkinHooks implements
// Special handling for talk pages
// Since talk keys have namespace as prefix
foreach ( $links['associated-pages'] as $key => $item ) {
// I wish I can use str_ends_with but need to wait for PHP 7.X to be dropped
if ( substr( (string)$key, -4 ) === 'talk' ) {
$keyStr = (string)$key;
// TODO: use str_ends_with when we drop PHP 7.X
if ( substr( $keyStr, -5 ) === '_talk' ) {
// Extract the namespace key from the talk key (e.g. Project from Project_talk)
// TODO: use str_starts_with when we drop PHP 7.X
$namespace = substr( $keyStr, 0, -5 );
$links['associated-pages'][$key]['icon'] = 'speechBubbles';
$links['associated-pages'][$namespace]['icon'] = 'article';
}
}

View file

@ -284,6 +284,7 @@
"defaultColor": "#000",
"class": "MediaWiki\\ResourceLoader\\OOUIIconPackModule",
"icons": [
"arrowPrevious",
"article",
"articleNotFound",
"articleRedirect",