From 732cc2390e4d79744a3e721ffcc8217488af244b Mon Sep 17 00:00:00 2001 From: Fomafix Date: Thu, 17 Sep 2015 05:35:29 +0000 Subject: [PATCH] Load the module mediawiki.page.watch.ajax only when needed Load the module mediawiki.page.watch.ajax only when there is a watch button on the page. This change uses the same checks as buildContentNavigationUrls() in SkinTemplate.php. Also combine two if checks. Bug: T112523 Change-Id: I78895ffea1290f8c1d90630851d0d3d443800d66 --- includes/skins/Skin.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 53af3e7da9..be08e4c17e 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -200,16 +200,15 @@ abstract class Skin extends ContextSource { ); // Add various resources if required - if ( $wgUseAjax ) { - if ( $wgEnableAPI ) { - if ( $wgEnableWriteAPI && $wgAjaxWatch && $user->isLoggedIn() - && $user->isAllowed( 'writeapi' ) - ) { - $modules['watch'][] = 'mediawiki.page.watch.ajax'; - } - - $modules['search'][] = 'mediawiki.searchSuggest'; + if ( $wgUseAjax && $wgEnableAPI ) { + if ( $wgEnableWriteAPI && $wgAjaxWatch && $user->isLoggedIn() + && $user->isAllowedAll( 'writeapi', 'viewmywatchlist', 'editmywatchlist' ) + && $this->getRelevantTitle()->canExist() + ) { + $modules['watch'][] = 'mediawiki.page.watch.ajax'; } + + $modules['search'][] = 'mediawiki.searchSuggest'; } if ( $user->getBoolOption( 'editsectiononrightclick' ) ) { -- 2.20.1