73 if ( !$user->isRegistered() ) {
74 $this->
dieWithError(
'watchlistanontext',
'notloggedin' );
84 $pageSet = $this->getPageSet();
85 if ( $params[
'entirewatchlist'] && $pageSet->getDataSource() !==
null ) {
88 'apierror-invalidparammix-cannotusewith',
90 $pageSet->encodeParamName( $pageSet->getDataSource() )
96 $dbw = $this->dbProvider->getPrimaryDatabase();
99 if ( isset( $params[
'timestamp'] ) ) {
100 $timestamp = $dbw->timestamp( $params[
'timestamp'] );
103 if ( !$params[
'entirewatchlist'] ) {
107 if ( isset( $params[
'torevid'] ) ) {
108 if ( $params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
111 $titles = $pageSet->getGoodPages();
112 $title = reset( $titles );
115 $timestamp = $this->revisionStore->getTimestampFromId(
117 IDBAccessObject::READ_LATEST
120 $timestamp = $dbw->timestamp( $timestamp );
125 } elseif ( isset( $params[
'newerthanrevid'] ) ) {
126 if ( $params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
129 $titles = $pageSet->getGoodPages();
130 $title = reset( $titles );
133 $currRev = $this->revisionStore->getRevisionById(
134 $params[
'newerthanrevid'],
135 IDBAccessObject::READ_LATEST
138 $nextRev = $this->revisionStore->getNextRevision(
140 IDBAccessObject::READ_LATEST
143 $timestamp = $dbw->timestamp( $nextRev->getTimestamp() );
151 if ( $params[
'entirewatchlist'] ) {
153 $this->watchedItemStore->resetAllNotificationTimestampsForUser( $user, $timestamp );
155 $result[
'notificationtimestamp'] = $timestamp ===
null
160 foreach ( $pageSet->getInvalidTitlesAndReasons() as $r ) {
161 $r[
'invalid'] =
true;
164 foreach ( $pageSet->getMissingPageIDs() as $p ) {
166 $page[
'pageid'] = $p;
167 $page[
'missing'] =
true;
168 $page[
'notwatched'] =
true;
171 foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
174 $rev[
'missing'] =
true;
175 $rev[
'notwatched'] =
true;
179 $pages = $pageSet->getPages();
182 $this->watchedItemStore->setNotificationTimestampsForUser(
189 $timestamps = $this->watchedItemStore->getNotificationTimestampsBatch(
196 foreach ( $pages as $page ) {
197 $ns = $page->getNamespace();
198 $dbkey = $page->getDBkey();
201 'title' => $this->titleFormatter->getPrefixedText( $page ),
203 if ( !$page->exists() ) {
204 $r[
'missing'] =
true;
205 $title = $this->titleFactory->newFromPageIdentity( $page );
206 if ( $title->isKnown() ) {
210 if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] )
211 && $timestamps[$ns][$dbkey] !==
false
213 $r[
'notificationtimestamp'] =
'';
214 if ( $timestamps[$ns][$dbkey] !==
null ) {
215 $r[
'notificationtimestamp'] =
wfTimestamp( TS_ISO_8601, $timestamps[$ns][$dbkey] );
218 $r[
'notwatched'] =
true;
226 $apiResult->addValue(
null, $this->
getModuleName(), $result );
229 $continuationManager->setContinuationIntoResult( $apiResult );