From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/actions/WatchAction.php | 59 ++++++++++++---------------------------- 1 file changed, 17 insertions(+), 42 deletions(-) (limited to 'includes/actions/WatchAction.php') diff --git a/includes/actions/WatchAction.php b/includes/actions/WatchAction.php index 929c1b5f..8c9a46a5 100644 --- a/includes/actions/WatchAction.php +++ b/includes/actions/WatchAction.php @@ -1,6 +1,6 @@ getTitle(), $this->getUser() ); wfProfileOut( __METHOD__ ); + return true; } @@ -81,10 +82,10 @@ class WatchAction extends FormAction { protected function checkCanExecute( User $user ) { // Must be logged in if ( $user->isAnon() ) { - throw new ErrorPageError( 'watchnologin', 'watchnologintext' ); + throw new UserNotLoggedIn( 'watchlistanontext', 'watchnologin' ); } - return parent::checkCanExecute( $user ); + parent::checkCanExecute( $user ); } /** @@ -96,7 +97,9 @@ class WatchAction extends FormAction { * @return Status */ public static function doWatchOrUnwatch( $watch, Title $title, User $user ) { - if ( $user->isLoggedIn() && $user->isWatched( $title, WatchedItem::IGNORE_USER_RIGHTS ) != $watch ) { + if ( $user->isLoggedIn() && + $user->isWatched( $title, WatchedItem::IGNORE_USER_RIGHTS ) != $watch + ) { // If the user doesn't have 'editmywatchlist', we still want to // allow them to add but not remove items via edits and such. if ( $watch ) { @@ -105,6 +108,7 @@ class WatchAction extends FormAction { return self::doUnwatch( $title, $user ); } } + return Status::newGood(); } @@ -116,8 +120,12 @@ class WatchAction extends FormAction { * @param int $checkRights Passed through to $user->addWatch() * @return Status */ - public static function doWatch( Title $title, User $user, $checkRights = WatchedItem::CHECK_USER_RIGHTS ) { - if ( $checkRights !== WatchedItem::IGNORE_USER_RIGHTS && !$user->isAllowed( 'editmywatchlist' ) ) { + public static function doWatch( Title $title, User $user, + $checkRights = WatchedItem::CHECK_USER_RIGHTS + ) { + if ( $checkRights !== WatchedItem::IGNORE_USER_RIGHTS && + !$user->isAllowed( 'editmywatchlist' ) + ) { return User::newFatalPermissionDeniedStatus( 'editmywatchlist' ); } @@ -129,6 +137,7 @@ class WatchAction extends FormAction { $user->addWatch( $title, $checkRights ); wfRunHooks( 'WatchArticleComplete', array( &$user, &$page ) ); } + return $status; } @@ -152,6 +161,7 @@ class WatchAction extends FormAction { $user->removeWatch( $title ); wfRunHooks( 'UnwatchArticleComplete', array( &$user, &$page ) ); } + return $status; } @@ -168,7 +178,7 @@ class WatchAction extends FormAction { if ( $action != 'unwatch' ) { $action = 'watch'; } - $salt = array( $action, $title->getDBkey() ); + $salt = array( $action, $title->getPrefixedDBkey() ); // This token stronger salted and not compatible with ApiWatch // It's title/action specific because index.php is GET and API is POST @@ -200,38 +210,3 @@ class WatchAction extends FormAction { $this->getOutput()->addWikiMsg( 'addedwatchtext', $this->getTitle()->getPrefixedText() ); } } - -/** - * Page removal from a user's watchlist - * - * @ingroup Actions - */ -class UnwatchAction extends WatchAction { - - public function getName() { - return 'unwatch'; - } - - protected function getDescription() { - return $this->msg( 'removewatch' )->escaped(); - } - - public function onSubmit( $data ) { - wfProfileIn( __METHOD__ ); - self::doUnwatch( $this->getTitle(), $this->getUser() ); - wfProfileOut( __METHOD__ ); - return true; - } - - protected function alterForm( HTMLForm $form ) { - $form->setSubmitTextMsg( 'confirm-unwatch-button' ); - } - - protected function preText() { - return $this->msg( 'confirm-unwatch-top' )->parse(); - } - - public function onSuccess() { - $this->getOutput()->addWikiMsg( 'removedwatchtext', $this->getTitle()->getPrefixedText() ); - } -} -- cgit v1.2.2