79 if ( !$user->isRegistered() ) {
80 $this->
dieWithError(
'watchlistanontext',
'notloggedin' );
90 $pageSet = $this->getPageSet();
91 if (
$params[
'entirewatchlist'] && $pageSet->getDataSource() !==
null ) {
94 'apierror-invalidparammix-cannotusewith',
96 $pageSet->encodeParamName( $pageSet->getDataSource() )
102 $dbw = $this->dbProvider->getPrimaryDatabase();
105 if ( isset(
$params[
'timestamp'] ) ) {
106 $timestamp = $dbw->timestamp(
$params[
'timestamp'] );
109 if ( !
$params[
'entirewatchlist'] ) {
113 if ( isset(
$params[
'torevid'] ) ) {
114 if (
$params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
117 $titles = $pageSet->getGoodPages();
118 $title = reset( $titles );
121 $timestamp = $this->revisionStore->getTimestampFromId(
123 IDBAccessObject::READ_LATEST
126 $timestamp = $dbw->timestamp( $timestamp );
131 } elseif ( isset(
$params[
'newerthanrevid'] ) ) {
132 if (
$params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
135 $titles = $pageSet->getGoodPages();
136 $title = reset( $titles );
139 $currRev = $this->revisionStore->getRevisionById(
141 IDBAccessObject::READ_LATEST
144 $nextRev = $this->revisionStore->getNextRevision(
146 IDBAccessObject::READ_LATEST
149 $timestamp = $dbw->timestamp( $nextRev->getTimestamp() );
157 if (
$params[
'entirewatchlist'] ) {
159 $this->watchedItemStore->resetAllNotificationTimestampsForUser( $user, $timestamp );
161 $result[
'notificationtimestamp'] = $timestamp ===
null
166 foreach ( $pageSet->getInvalidTitlesAndReasons() as $r ) {
167 $r[
'invalid'] =
true;
170 foreach ( $pageSet->getMissingPageIDs() as $p ) {
172 $page[
'pageid'] = $p;
173 $page[
'missing'] =
true;
174 $page[
'notwatched'] =
true;
177 foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
180 $rev[
'missing'] =
true;
181 $rev[
'notwatched'] =
true;
185 $pages = $pageSet->getPages();
188 $this->watchedItemStore->setNotificationTimestampsForUser(
195 $timestamps = $this->watchedItemStore->getNotificationTimestampsBatch(
202 foreach ( $pages as $page ) {
203 $ns = $page->getNamespace();
204 $dbkey = $page->getDBkey();
207 'title' => $this->titleFormatter->getPrefixedText( $page ),
209 if ( !$page->exists() ) {
210 $r[
'missing'] =
true;
211 $title = $this->titleFactory->newFromPageIdentity( $page );
212 if ( $title->isKnown() ) {
216 if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] )
217 && $timestamps[$ns][$dbkey] !==
false
219 $r[
'notificationtimestamp'] =
'';
220 if ( $timestamps[$ns][$dbkey] !==
null ) {
221 $r[
'notificationtimestamp'] =
wfTimestamp( TS_ISO_8601, $timestamps[$ns][$dbkey] );
224 $r[
'notwatched'] =
true;
230 ApiResult::setIndexedTagName( $result,
'page' );
232 $apiResult->addValue(
null, $this->
getModuleName(), $result );
235 $continuationManager->setContinuationIntoResult( $apiResult );