71 if ( !$user->isRegistered() ) {
72 $this->
dieWithError(
'watchlistanontext',
'notloggedin' );
82 $pageSet = $this->getPageSet();
83 if ( $params[
'entirewatchlist'] && $pageSet->getDataSource() !==
null ) {
86 'apierror-invalidparammix-cannotusewith',
88 $pageSet->encodeParamName( $pageSet->getDataSource() )
94 $dbw = $this->loadBalancer->getConnectionRef(
DB_PRIMARY );
97 if ( isset( $params[
'timestamp'] ) ) {
98 $timestamp = $dbw->timestamp( $params[
'timestamp'] );
101 if ( !$params[
'entirewatchlist'] ) {
105 if ( isset( $params[
'torevid'] ) ) {
106 if ( $params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
109 $titles = $pageSet->getGoodTitles();
110 $title = reset( $titles );
113 $timestamp = $this->revisionStore->getTimestampFromId(
115 IDBAccessObject::READ_LATEST
118 $timestamp = $dbw->timestamp( $timestamp );
123 } elseif ( isset( $params[
'newerthanrevid'] ) ) {
124 if ( $params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
127 $titles = $pageSet->getGoodTitles();
128 $title = reset( $titles );
131 $currRev = $this->revisionStore->getRevisionById(
132 $params[
'newerthanrevid'],
136 $nextRev = $this->revisionStore->getNextRevision(
141 $timestamp = $dbw->timestamp( $nextRev->getTimestamp() );
149 if ( $params[
'entirewatchlist'] ) {
151 $this->watchedItemStore->resetAllNotificationTimestampsForUser( $user, $timestamp );
153 $result[
'notificationtimestamp'] = $timestamp ===
null
158 foreach ( $pageSet->getInvalidTitlesAndReasons() as $r ) {
159 $r[
'invalid'] =
true;
162 foreach ( $pageSet->getMissingPageIDs() as $p ) {
164 $page[
'pageid'] = $p;
165 $page[
'missing'] =
true;
166 $page[
'notwatched'] =
true;
169 foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
172 $rev[
'missing'] =
true;
173 $rev[
'notwatched'] =
true;
177 if ( $pageSet->getPages() ) {
179 $this->watchedItemStore->setNotificationTimestampsForUser(
186 $timestamps = $this->watchedItemStore->getNotificationTimestampsBatch(
193 foreach ( $pageSet->getTitles() as
$title ) {
194 $ns =
$title->getNamespace();
195 $dbkey =
$title->getDBkey();
198 'title' =>
$title->getPrefixedText(),
200 if ( !
$title->exists() ) {
201 $r[
'missing'] =
true;
202 if (
$title->isKnown() ) {
206 if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] )
207 && $timestamps[$ns][$dbkey] !==
false
209 $r[
'notificationtimestamp'] =
'';
210 if ( $timestamps[$ns][$dbkey] !==
null ) {
211 $r[
'notificationtimestamp'] =
wfTimestamp( TS_ISO_8601, $timestamps[$ns][$dbkey] );
214 $r[
'notwatched'] =
true;
220 ApiResult::setIndexedTagName( $result,
'page' );
222 $apiResult->addValue(
null, $this->
getModuleName(), $result );
225 $continuationManager->setContinuationIntoResult( $apiResult );
254 'entirewatchlist' => [
255 ParamValidator::PARAM_TYPE =>
'boolean'
258 ParamValidator::PARAM_TYPE =>
'timestamp'
261 ParamValidator::PARAM_TYPE =>
'integer'
263 'newerthanrevid' => [
264 ParamValidator::PARAM_TYPE =>
'integer'
271 $result += $this->getPageSet()->getFinalParams( $flags );