77 if ( !$user->isRegistered() ) {
78 $this->
dieWithError(
'watchlistanontext',
'notloggedin' );
88 $pageSet = $this->getPageSet();
89 if (
$params[
'entirewatchlist'] && $pageSet->getDataSource() !==
null ) {
92 'apierror-invalidparammix-cannotusewith',
94 $pageSet->encodeParamName( $pageSet->getDataSource() )
100 $dbw = $this->dbProvider->getPrimaryDatabase();
103 if ( isset(
$params[
'timestamp'] ) ) {
104 $timestamp = $dbw->timestamp(
$params[
'timestamp'] );
107 if ( !
$params[
'entirewatchlist'] ) {
111 if ( isset(
$params[
'torevid'] ) ) {
112 if (
$params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
115 $titles = $pageSet->getGoodPages();
116 $title = reset( $titles );
119 $timestamp = $this->revisionStore->getTimestampFromId(
121 IDBAccessObject::READ_LATEST
124 $timestamp = $dbw->timestamp( $timestamp );
129 } elseif ( isset(
$params[
'newerthanrevid'] ) ) {
130 if (
$params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
133 $titles = $pageSet->getGoodPages();
134 $title = reset( $titles );
137 $currRev = $this->revisionStore->getRevisionById(
139 IDBAccessObject::READ_LATEST
142 $nextRev = $this->revisionStore->getNextRevision(
144 IDBAccessObject::READ_LATEST
147 $timestamp = $dbw->timestamp( $nextRev->getTimestamp() );
155 if (
$params[
'entirewatchlist'] ) {
157 $this->watchedItemStore->resetAllNotificationTimestampsForUser( $user, $timestamp );
159 $result[
'notificationtimestamp'] = $timestamp ===
null
164 foreach ( $pageSet->getInvalidTitlesAndReasons() as $r ) {
165 $r[
'invalid'] =
true;
168 foreach ( $pageSet->getMissingPageIDs() as $p ) {
170 $page[
'pageid'] = $p;
171 $page[
'missing'] =
true;
172 $page[
'notwatched'] =
true;
175 foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
178 $rev[
'missing'] =
true;
179 $rev[
'notwatched'] =
true;
183 $pages = $pageSet->getPages();
186 $this->watchedItemStore->setNotificationTimestampsForUser(
193 $timestamps = $this->watchedItemStore->getNotificationTimestampsBatch(
200 foreach ( $pages as $page ) {
201 $ns = $page->getNamespace();
202 $dbkey = $page->getDBkey();
205 'title' => $this->titleFormatter->getPrefixedText( $page ),
207 if ( !$page->exists() ) {
208 $r[
'missing'] =
true;
209 $title = $this->titleFactory->newFromPageIdentity( $page );
210 if ( $title->isKnown() ) {
214 if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] )
215 && $timestamps[$ns][$dbkey] !==
false
217 $r[
'notificationtimestamp'] =
'';
218 if ( $timestamps[$ns][$dbkey] !==
null ) {
219 $r[
'notificationtimestamp'] =
wfTimestamp( TS_ISO_8601, $timestamps[$ns][$dbkey] );
222 $r[
'notwatched'] =
true;
228 ApiResult::setIndexedTagName( $result,
'page' );
230 $apiResult->addValue(
null, $this->
getModuleName(), $result );
233 $continuationManager->setContinuationIntoResult( $apiResult );