72 if ( !$user->isRegistered() ) {
73 $this->
dieWithError(
'watchlistanontext',
'notloggedin' );
83 $pageSet = $this->getPageSet();
84 if ( $params[
'entirewatchlist'] && $pageSet->getDataSource() !==
null ) {
87 'apierror-invalidparammix-cannotusewith',
89 $pageSet->encodeParamName( $pageSet->getDataSource() )
95 $dbw = $this->loadBalancer->getConnectionRef(
DB_PRIMARY );
98 if ( isset( $params[
'timestamp'] ) ) {
99 $timestamp = $dbw->timestamp( $params[
'timestamp'] );
102 if ( !$params[
'entirewatchlist'] ) {
106 if ( isset( $params[
'torevid'] ) ) {
107 if ( $params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
110 $titles = $pageSet->getGoodTitles();
111 $title = reset( $titles );
114 $timestamp = $this->revisionStore->getTimestampFromId(
116 IDBAccessObject::READ_LATEST
119 $timestamp = $dbw->timestamp( $timestamp );
124 } elseif ( isset( $params[
'newerthanrevid'] ) ) {
125 if ( $params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
128 $titles = $pageSet->getGoodTitles();
129 $title = reset( $titles );
132 $currRev = $this->revisionStore->getRevisionById(
133 $params[
'newerthanrevid'],
137 $nextRev = $this->revisionStore->getNextRevision(
142 $timestamp = $dbw->timestamp( $nextRev->getTimestamp() );
150 if ( $params[
'entirewatchlist'] ) {
152 $this->watchedItemStore->resetAllNotificationTimestampsForUser( $user, $timestamp );
154 $result[
'notificationtimestamp'] = $timestamp ===
null
159 foreach ( $pageSet->getInvalidTitlesAndReasons() as $r ) {
160 $r[
'invalid'] =
true;
163 foreach ( $pageSet->getMissingPageIDs() as $p ) {
165 $page[
'pageid'] = $p;
166 $page[
'missing'] =
true;
167 $page[
'notwatched'] =
true;
170 foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
173 $rev[
'missing'] =
true;
174 $rev[
'notwatched'] =
true;
178 if ( $pageSet->getPages() ) {
180 $this->watchedItemStore->setNotificationTimestampsForUser(
187 $timestamps = $this->watchedItemStore->getNotificationTimestampsBatch(
194 foreach ( $pageSet->getTitles() as
$title ) {
195 $ns =
$title->getNamespace();
196 $dbkey =
$title->getDBkey();
199 'title' =>
$title->getPrefixedText(),
201 if ( !
$title->exists() ) {
202 $r[
'missing'] =
true;
203 if (
$title->isKnown() ) {
207 if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] )
208 && $timestamps[$ns][$dbkey] !==
false
210 $r[
'notificationtimestamp'] =
'';
211 if ( $timestamps[$ns][$dbkey] !==
null ) {
212 $r[
'notificationtimestamp'] =
wfTimestamp( TS_ISO_8601, $timestamps[$ns][$dbkey] );
215 $r[
'notwatched'] =
true;
221 ApiResult::setIndexedTagName( $result,
'page' );
223 $apiResult->addValue(
null, $this->
getModuleName(), $result );
226 $continuationManager->setContinuationIntoResult( $apiResult );
253 'entirewatchlist' => [
254 ParamValidator::PARAM_TYPE =>
'boolean'
257 ParamValidator::PARAM_TYPE =>
'timestamp'
260 ParamValidator::PARAM_TYPE =>
'integer'
262 'newerthanrevid' => [
263 ParamValidator::PARAM_TYPE =>
'integer'
270 $result += $this->getPageSet()->getFinalParams( $flags );