Favor SkinTemplateNavigation::Universal

This hook is run on every page. The SkinTemplateNavigation hook
counter intutively is run only on pages which can exist. I think
it's clearer if we only use SkinTemplateNavigation::Universal hook
and keep the logic for when it runs inside our own code.

Bug: T255319
Change-Id: I0835074a6cadf6e9bdcc45299de37dd9328bf9b2
This commit is contained in:
jdlrobson 2020-06-12 14:43:58 -07:00 committed by Ammarpad
parent 249ef2ecee
commit e7df44a66d
3 changed files with 5 additions and 2 deletions

View file

@ -119,9 +119,11 @@ class Hooks {
* @param array &$content_navigation
*/
public static function onSkinTemplateNavigation( $sk, &$content_navigation ) {
$title = $sk->getRelevantTitle();
if (
$sk->getConfig()->get( 'VectorUseIconWatch' ) &&
$sk->getSkinName() === 'vector' &&
$sk->getConfig()->get( 'VectorUseIconWatch' )
$title && $title->canExist()
) {
$key = null;
if ( isset( $content_navigation['actions']['watch'] ) ) {

View file

@ -59,7 +59,7 @@
"SkinPageReadyConfig": "Vector\\Hooks::onSkinPageReadyConfig",
"GetPreferences": "Vector\\Hooks::onGetPreferences",
"PreferencesFormPreSave": "Vector\\Hooks::onPreferencesFormPreSave",
"SkinTemplateNavigation": "Vector\\Hooks::onSkinTemplateNavigation",
"SkinTemplateNavigation::Universal": "Vector\\Hooks::onSkinTemplateNavigation",
"LocalUserCreated": "Vector\\Hooks::onLocalUserCreated",
"OutputPageBodyAttributes": "Vector\\Hooks::onOutputPageBodyAttributes",
"MakeGlobalVariablesScript": "Vector\\Hooks::onMakeGlobalVariablesScript"

View file

@ -289,6 +289,7 @@ class VectorHooksTest extends \MediaWikiTestCase {
'wgVectorUseIconWatch' => true
] );
$skin = new SkinVector( [ 'name' => 'vector' ] );
$skin->getContext()->setTitle( Title::newFromText( 'Foo' ) );
$contentNavWatch = [
'actions' => [
'watch' => [ 'class' => 'watch' ],