78 if ( !$user->isRegistered() ) {
79 $this->
dieWithError(
'watchlistanontext',
'notloggedin' );
89 $pageSet = $this->getPageSet();
90 if (
$params[
'entirewatchlist'] && $pageSet->getDataSource() !==
null ) {
93 'apierror-invalidparammix-cannotusewith',
95 $pageSet->encodeParamName( $pageSet->getDataSource() )
101 $dbw = $this->dbProvider->getPrimaryDatabase();
104 if ( isset(
$params[
'timestamp'] ) ) {
105 $timestamp = $dbw->timestamp(
$params[
'timestamp'] );
108 if ( !
$params[
'entirewatchlist'] ) {
112 if ( isset(
$params[
'torevid'] ) ) {
113 if (
$params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
116 $titles = $pageSet->getGoodPages();
117 $title = reset( $titles );
120 $timestamp = $this->revisionStore->getTimestampFromId(
122 IDBAccessObject::READ_LATEST
125 $timestamp = $dbw->timestamp( $timestamp );
130 } elseif ( isset(
$params[
'newerthanrevid'] ) ) {
131 if (
$params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
134 $titles = $pageSet->getGoodPages();
135 $title = reset( $titles );
138 $currRev = $this->revisionStore->getRevisionById(
140 IDBAccessObject::READ_LATEST
143 $nextRev = $this->revisionStore->getNextRevision(
145 IDBAccessObject::READ_LATEST
148 $timestamp = $dbw->timestamp( $nextRev->getTimestamp() );
156 if (
$params[
'entirewatchlist'] ) {
158 $this->watchedItemStore->resetAllNotificationTimestampsForUser( $user, $timestamp );
160 $result[
'notificationtimestamp'] = $timestamp ===
null
165 foreach ( $pageSet->getInvalidTitlesAndReasons() as $r ) {
166 $r[
'invalid'] =
true;
169 foreach ( $pageSet->getMissingPageIDs() as $p ) {
171 $page[
'pageid'] = $p;
172 $page[
'missing'] =
true;
173 $page[
'notwatched'] =
true;
176 foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
179 $rev[
'missing'] =
true;
180 $rev[
'notwatched'] =
true;
184 $pages = $pageSet->getPages();
187 $this->watchedItemStore->setNotificationTimestampsForUser(
194 $timestamps = $this->watchedItemStore->getNotificationTimestampsBatch(
201 foreach ( $pages as $page ) {
202 $ns = $page->getNamespace();
203 $dbkey = $page->getDBkey();
206 'title' => $this->titleFormatter->getPrefixedText( $page ),
208 if ( !$page->exists() ) {
209 $r[
'missing'] =
true;
210 $title = $this->titleFactory->newFromPageIdentity( $page );
211 if ( $title->isKnown() ) {
215 if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] )
216 && $timestamps[$ns][$dbkey] !==
false
218 $r[
'notificationtimestamp'] =
'';
219 if ( $timestamps[$ns][$dbkey] !==
null ) {
220 $r[
'notificationtimestamp'] =
wfTimestamp( TS_ISO_8601, $timestamps[$ns][$dbkey] );
223 $r[
'notwatched'] =
true;
229 ApiResult::setIndexedTagName( $result,
'page' );
231 $apiResult->addValue(
null, $this->
getModuleName(), $result );
234 $continuationManager->setContinuationIntoResult( $apiResult );