From 2fce68778c3ae07ab4044447dda5f8739789b4fc Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 28 Apr 2019 02:07:20 +0300 Subject: [PATCH] Replaces $user->isWatching call with WatchedItemStore isWatching service call Bug: T208766 Change-Id: I178b1a1aa0106d82f1b336f2bda5c6371468d741 --- includes/VectorTemplate.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/VectorTemplate.php b/includes/VectorTemplate.php index b9d3339..6411d99 100644 --- a/includes/VectorTemplate.php +++ b/includes/VectorTemplate.php @@ -22,6 +22,8 @@ * @ingroup Skins */ +use MediaWiki\MediaWikiServices; + /** * QuickTemplate subclass for Vector * @ingroup Skins @@ -41,9 +43,16 @@ class VectorTemplate extends BaseTemplate { // Move the watch/unwatch star outside of the collapsed "actions" menu to the main "views" menu if ( $this->config->get( 'VectorUseIconWatch' ) ) { - $mode = $this->getSkin()->getUser()->isWatched( $this->getSkin()->getRelevantTitle() ) - ? 'unwatch' - : 'watch'; + $mode = ( $this->getSkin()->getRelevantTitle()->isWatchable() && + MediaWikiServices::getInstance()->getPermissionManager()->userHasRight( + $this->getSkin()->getUser(), + 'viewmywatchlist' + ) && + MediaWikiServices::getInstance()->getWatchedItemStore()->isWatched( + $this->getSkin()->getUser(), + $this->getSkin()->getRelevantTitle() + ) + ) ? 'unwatch' : 'watch'; if ( isset( $this->data['action_urls'][$mode] ) ) { $this->data['view_urls'][$mode] = $this->data['action_urls'][$mode];