// title is still supported for backward compatibility
if ( !isset( $params['title'] ) ) {
$pageSet->execute();
- $res = $pageSet->getInvalidTitlesAndRevisions( array( 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'interwikiTitles' ) );
+ $res = $pageSet->getInvalidTitlesAndRevisions( array(
+ 'invalidTitles',
+ 'special',
+ 'missingIds',
+ 'missingRevIds',
+ 'interwikiTitles'
+ ) );
+
foreach ( $pageSet->getMissingTitles() as $title ) {
$r = $this->watchTitle( $title, $user, $params );
$r['missing'] = 1;
$res[] = $r;
}
+
foreach ( $pageSet->getGoodTitles() as $title ) {
$r = $this->watchTitle( $title, $user, $params );
$res[] = $r;
$extraParams = array_keys( array_filter( $pageSet->extractRequestParams(), function ( $x ) {
return $x !== null && $x !== false;
} ) );
+
if ( $extraParams ) {
$p = $this->getModulePrefix();
- $this->dieUsage( "The parameter {$p}title can not be used with ". implode( ", ", $extraParams ), 'invalidparammix' );
+ $this->dieUsage(
+ "The parameter {$p}title can not be used with " . implode( ", ", $extraParams ),
+ 'invalidparammix'
+ );
}
$title = Title::newFromText( $params['title'] );
$this->getResult()->addValue( null, $this->getModuleName(), $res );
}
- private function watchTitle( Title $title, User $user, array $params, $compatibilityMode = false ) {
+ private function watchTitle( Title $title, User $user, array $params,
+ $compatibilityMode = false
+ ) {
if ( !$title->isWatchable() ) {
return array( 'title' => $title->getPrefixedText(), 'watchable' => 0 );
}
$this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
}
-
if ( !$status->isOK() ) {
if ( $compatibilityMode ) {
$this->dieStatus( $status );
}
- $res['error'] = $this->getErrorFromStatus( $status );
+ $res['error'] = $this->getErrorFromStatus( $status );
}
+
return $res;
}
-
/**
* Get a cached instance of an ApiPageSet object
* @return ApiPageSet
if ( $this->mPageSet === null ) {
$this->mPageSet = new ApiPageSet( $this );
}
+
return $this->mPageSet;
}
if ( $flags ) {
$result += $this->getPageSet()->getFinalParams( $flags );
}
+
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',
}
public function getDescription() {
- return 'Add or remove pages from/to the current user\'s watchlist';
+ return 'Add or remove pages from/to the current user\'s watchlist.';
}
public function getPossibleErrors() {