summaryrefslogtreecommitdiff
path: root/includes/api/ApiWatch.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /includes/api/ApiWatch.php
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
Diffstat (limited to 'includes/api/ApiWatch.php')
-rw-r--r--includes/api/ApiWatch.php58
1 files changed, 18 insertions, 40 deletions
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',
);
}