+ $continuationManager = new ApiContinuationManager( $this, [], [] );
+ $this->setContinuationManager( $continuationManager );
+
+ $pageSet = $this->getPageSet();
+ // by default we use pageset to extract the page to work on.
+ // title is still supported for backward compatibility
+ if ( !isset( $params['title'] ) ) {
+ $pageSet->execute();
+ $res = $pageSet->getInvalidTitlesAndRevisions( [
+ 'invalidTitles',
+ 'special',
+ 'missingIds',
+ 'missingRevIds',
+ 'interwikiTitles'
+ ] );
+
+ foreach ( $pageSet->getMissingTitles() as $title ) {
+ $r = $this->watchTitle( $title, $user, $params );
+ $r['missing'] = true;
+ $res[] = $r;
+ }
+
+ foreach ( $pageSet->getGoodTitles() as $title ) {
+ $r = $this->watchTitle( $title, $user, $params );
+ $res[] = $r;
+ }
+ 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 ) {
+ return $x !== null && $x !== false;
+ } ) );
+
+ if ( $extraParams ) {
+ $this->dieWithError(
+ [
+ 'apierror-invalidparammix-cannotusewith',
+ $this->encodeParamName( 'title' ),
+ $pageSet->encodeParamName( $extraParams[0] )
+ ],
+ 'invalidparammix'
+ );
+ }
+
+ $title = Title::newFromText( $params['title'] );
+ if ( !$title || !$title->isWatchable() ) {
+ $this->dieWithError( [ 'invalidtitle', $params['title'] ] );
+ }
+ $res = $this->watchTitle( $title, $user, $params, true );