39 if ( $user->isAnon() ) {
40 $this->
dieWithError(
'watchlistanontext',
'notloggedin' );
51 if ( $params[
'entirewatchlist'] && $pageSet->getDataSource() !==
null ) {
54 'apierror-invalidparammix-cannotusewith',
56 $pageSet->encodeParamName( $pageSet->getDataSource() )
65 if ( isset( $params[
'timestamp'] ) ) {
66 $timestamp = $dbw->timestamp( $params[
'timestamp'] );
69 if ( !$params[
'entirewatchlist'] ) {
73 if ( isset( $params[
'torevid'] ) ) {
74 if ( $params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
77 $titles = $pageSet->getGoodTitles();
81 $timestamp = MediaWikiServices::getInstance()->getRevisionStore()
82 ->getTimestampFromId( $params[
'torevid'], IDBAccessObject::READ_LATEST );
84 $timestamp = $dbw->timestamp( $timestamp );
89 } elseif ( isset( $params[
'newerthanrevid'] ) ) {
90 if ( $params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
93 $titles = $pageSet->getGoodTitles();
97 $rl = MediaWikiServices::getInstance()->getRevisionLookup();
98 $currRev = $rl->getRevisionById( $params[
'newerthanrevid'], Title::READ_LATEST );
100 $nextRev = $rl->getNextRevision( $currRev, Title::READ_LATEST );
102 $timestamp = $dbw->timestamp( $nextRev->getTimestamp() );
108 $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
111 if ( $params[
'entirewatchlist'] ) {
113 $watchedItemStore->resetAllNotificationTimestampsForUser( $user, $timestamp );
115 $result[
'notificationtimestamp'] = $timestamp ===
null
120 foreach ( $pageSet->getInvalidTitlesAndReasons() as $r ) {
121 $r[
'invalid'] =
true;
124 foreach ( $pageSet->getMissingPageIDs() as $p ) {
126 $page[
'pageid'] = $p;
127 $page[
'missing'] =
true;
128 $page[
'notwatched'] =
true;
131 foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
134 $rev[
'missing'] =
true;
135 $rev[
'notwatched'] =
true;
139 if ( $pageSet->getTitles() ) {
141 $watchedItemStore->setNotificationTimestampsForUser(
144 $pageSet->getTitles()
148 $timestamps = $watchedItemStore->getNotificationTimestampsBatch(
150 $pageSet->getTitles()
155 foreach ( $pageSet->getTitles() as
$title ) {
156 $ns =
$title->getNamespace();
157 $dbkey =
$title->getDBkey();
160 'title' =>
$title->getPrefixedText(),
162 if ( !
$title->exists() ) {
163 $r[
'missing'] =
true;
164 if (
$title->isKnown() ) {
168 if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] ) ) {
169 $r[
'notificationtimestamp'] =
'';
170 if ( $timestamps[$ns][$dbkey] !==
null ) {
171 $r[
'notificationtimestamp'] =
wfTimestamp( TS_ISO_8601, $timestamps[$ns][$dbkey] );
174 $r[
'notwatched'] =
true;
180 ApiResult::setIndexedTagName( $result,
'page' );
182 $apiResult->addValue(
null, $this->
getModuleName(), $result );
185 $continuationManager->setContinuationIntoResult( $apiResult );