From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- includes/api/ApiWatch.php | 58 +++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) (limited to 'includes/api/ApiWatch.php') diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index e6a660b3..85d051de 100644 --- a/includes/api/ApiWatch.php +++ b/includes/api/ApiWatch.php @@ -44,7 +44,8 @@ class ApiWatch extends ApiBase { $params = $this->extractRequestParams(); - $this->getResult()->beginContinuation( $params['continue'], array(), array() ); + $continuationManager = new ApiContinuationManager( $this, array(), array() ); + $this->setContinuationManager( $continuationManager ); $pageSet = $this->getPageSet(); // by default we use pageset to extract the page to work on. @@ -69,7 +70,7 @@ class ApiWatch extends ApiBase { $r = $this->watchTitle( $title, $user, $params ); $res[] = $r; } - $this->getResult()->setIndexedTagName( $res, 'w' ); + ApiResult::setIndexedTagName( $res, 'w' ); } else { // dont allow use of old title parameter with new pageset parameters. $extraParams = array_keys( array_filter( $pageSet->extractRequestParams(), function ( $x ) { @@ -92,7 +93,9 @@ class ApiWatch extends ApiBase { $res = $this->watchTitle( $title, $user, $params, true ); } $this->getResult()->addValue( null, $this->getModuleName(), $res ); - $this->getResult()->endContinuation(); + + $this->setContinuationManager( null ); + $continuationManager->setContinuationIntoResult( $this->getResult() ); } private function watchTitle( Title $title, User $user, array $params, @@ -104,37 +107,22 @@ class ApiWatch extends ApiBase { $res = array( 'title' => $title->getPrefixedText() ); - // Currently unnecessary, code to act as a safeguard against any change - // in current behavior of uselang. - // Copy from ApiParse - $oldLang = null; - if ( isset( $params['uselang'] ) && - $params['uselang'] != $this->getContext()->getLanguage()->getCode() - ) { - $oldLang = $this->getContext()->getLanguage(); // Backup language - $this->getContext()->setLanguage( Language::factory( $params['uselang'] ) ); - } - if ( $params['unwatch'] ) { $status = UnwatchAction::doUnwatch( $title, $user ); + $res['unwatched'] = $status->isOK(); if ( $status->isOK() ) { - $res['unwatched'] = ''; $res['message'] = $this->msg( 'removedwatchtext', $title->getPrefixedText() ) ->title( $title )->parseAsBlock(); } } else { $status = WatchAction::doWatch( $title, $user ); + $res['watched'] = $status->isOK(); if ( $status->isOK() ) { - $res['watched'] = ''; $res['message'] = $this->msg( 'addedwatchtext', $title->getPrefixedText() ) ->title( $title )->parseAsBlock(); } } - if ( !is_null( $oldLang ) ) { - $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang - } - if ( !$status->isOK() ) { if ( $compatibilityMode ) { $this->dieStatus( $status ); @@ -176,8 +164,9 @@ class ApiWatch extends ApiBase { ApiBase::PARAM_DEPRECATED => true ), 'unwatch' => false, - 'uselang' => null, - 'continue' => '', + 'continue' => array( + ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', + ), ); if ( $flags ) { $result += $this->getPageSet()->getFinalParams( $flags ); @@ -186,25 +175,14 @@ class ApiWatch extends ApiBase { return $result; } - public function getParamDescription() { - $psModule = $this->getPageSet(); - - return $psModule->getParamDescription() + array( - 'title' => 'The page to (un)watch. use titles instead', - 'unwatch' => 'If set the page will be unwatched rather than watched', - 'uselang' => 'Language to show the message in', - 'continue' => 'When more results are available, use this to continue', - ); - } - - public function getDescription() { - return 'Add or remove pages from/to the current user\'s watchlist.'; - } - - public function getExamples() { + protected function getExamplesMessages() { return array( - 'api.php?action=watch&titles=Main_Page' => 'Watch the page "Main Page"', - 'api.php?action=watch&titles=Main_Page&unwatch=' => 'Unwatch the page "Main Page"', + 'action=watch&titles=Main_Page&token=123ABC' + => 'apihelp-watch-example-watch', + 'action=watch&titles=Main_Page&unwatch=&token=123ABC' + => 'apihelp-watch-example-unwatch', + 'action=watch&generator=allpages&gapnamespace=0&token=123ABC' + => 'apihelp-watch-example-generator', ); } -- cgit v1.2.2