38 parent::__construct( $query, $moduleName,
'wl' );
46 $this->
run( $resultPageSet );
59 private function run( $resultPageSet =
null ) {
67 if ( !is_null( $params[
'prop'] ) && is_null( $resultPageSet ) ) {
68 $prop = array_flip( $params[
'prop'] );
70 $this->fld_ids = isset( $prop[
'ids'] );
71 $this->fld_title = isset( $prop[
'title'] );
72 $this->fld_flags = isset( $prop[
'flags'] );
73 $this->fld_user = isset( $prop[
'user'] );
74 $this->fld_userid = isset( $prop[
'userid'] );
75 $this->fld_comment = isset( $prop[
'comment'] );
76 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
77 $this->fld_timestamp = isset( $prop[
'timestamp'] );
78 $this->fld_sizes = isset( $prop[
'sizes'] );
79 $this->fld_patrol = isset( $prop[
'patrol'] );
80 $this->fld_notificationtimestamp = isset( $prop[
'notificationtimestamp'] );
81 $this->fld_loginfo = isset( $prop[
'loginfo'] );
82 $this->fld_tags = isset( $prop[
'tags'] );
84 if ( $this->fld_patrol && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
85 $this->
dieWithError(
'apierror-permissiondenied-patrolflag',
'patrol' );
88 if ( $this->fld_comment || $this->fld_parsedcomment ) {
94 'dir' => $params[
'dir'] ===
'older'
99 if ( is_null( $resultPageSet ) ) {
105 if ( $params[
'start'] ) {
106 $options[
'start'] = $params[
'start'];
108 if ( $params[
'end'] ) {
113 if ( !is_null( $params[
'continue'] ) ) {
114 $cont = explode(
'|', $params[
'continue'] );
116 $continueTimestamp = $cont[0];
117 $continueId = (int)$cont[1];
119 $startFrom = [ $continueTimestamp, $continueId ];
122 if ( $wlowner !== $user ) {
123 $options[
'watchlistOwner'] = $wlowner;
124 $options[
'watchlistOwnerToken'] = $params[
'token'];
127 if ( !is_null( $params[
'namespace'] ) ) {
128 $options[
'namespaceIds'] = $params[
'namespace'];
131 if ( $params[
'allrev'] ) {
135 if ( !is_null( $params[
'show'] ) ) {
136 $show = array_flip( $params[
'show'] );
147 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
148 $this->
dieWithError(
'apierror-permissiondenied-patrolflag',
'permissiondenied' );
152 $options[
'filters'] = array_keys( $show );
155 if ( !is_null( $params[
'type'] ) ) {
161 }
catch ( Exception $e ) {
167 if ( !is_null( $params[
'user'] ) ) {
168 $options[
'onlyByUser'] = $params[
'user'];
170 if ( !is_null( $params[
'excludeuser'] ) ) {
171 $options[
'notByUser'] = $params[
'excludeuser'];
174 $options[
'limit'] = $params[
'limit'];
176 Hooks::run(
'ApiQueryWatchlistPrepareWatchedItemQueryServiceOptions', [
181 $watchedItemQuery = MediaWikiServices::getInstance()->getWatchedItemQueryService();
182 $items = $watchedItemQuery->getWatchedItemsWithRecentChangeInfo( $wlowner,
$options, $startFrom );
184 foreach ( $items as list( $watchedItem, $recentChangeInfo ) ) {
186 if ( is_null( $resultPageSet ) ) {
190 $startFrom = [ $recentChangeInfo[
'rc_timestamp'], $recentChangeInfo[
'rc_id'] ];
193 } elseif ( $params[
'allrev'] ) {
194 $ids[] = (int)$recentChangeInfo[
'rc_this_oldid'];
196 $ids[] = (int)$recentChangeInfo[
'rc_cur_id'];
200 if ( $startFrom !==
null ) {
204 if ( is_null( $resultPageSet ) ) {
209 } elseif ( $params[
'allrev'] ) {
210 $resultPageSet->populateFromRevisionIDs( $ids );
212 $resultPageSet->populateFromPageIDs( $ids );
218 if ( $this->fld_flags ) {
221 if ( $this->fld_user || $this->fld_userid ) {
224 if ( $this->fld_user ) {
227 if ( $this->fld_comment || $this->fld_parsedcomment ) {
230 if ( $this->fld_patrol ) {
234 if ( $this->fld_sizes ) {
237 if ( $this->fld_loginfo ) {
240 if ( $this->fld_tags ) {
243 return $includeFields;
270 $type = (int)$recentChangeInfo[
'rc_type'];
275 if ( $this->fld_title || $this->fld_ids ) {
278 $vals[
'actionhidden'] =
true;
283 $recentChangeInfo[
'rc_deleted'],
288 if ( $this->fld_title ) {
291 if ( $this->fld_ids ) {
292 $vals[
'pageid'] = (int)$recentChangeInfo[
'rc_cur_id'];
293 $vals[
'revid'] = (int)$recentChangeInfo[
'rc_this_oldid'];
294 $vals[
'old_revid'] = (int)$recentChangeInfo[
'rc_last_oldid'];
300 if ( $this->fld_user || $this->fld_userid ) {
301 if ( $recentChangeInfo[
'rc_deleted'] & RevisionRecord::DELETED_USER ) {
302 $vals[
'userhidden'] =
true;
305 if ( RevisionRecord::userCanBitfield(
306 $recentChangeInfo[
'rc_deleted'],
307 RevisionRecord::DELETED_USER,
310 if ( $this->fld_userid ) {
311 $vals[
'userid'] = (int)$recentChangeInfo[
'rc_user'];
313 $vals[
'user'] = (int)$recentChangeInfo[
'rc_user'];
316 if ( $this->fld_user ) {
317 $vals[
'user'] = $recentChangeInfo[
'rc_user_text'];
320 if ( !$recentChangeInfo[
'rc_user'] ) {
321 $vals[
'anon'] =
true;
327 if ( $this->fld_flags ) {
328 $vals[
'bot'] = (bool)$recentChangeInfo[
'rc_bot'];
329 $vals[
'new'] = $recentChangeInfo[
'rc_type'] ==
RC_NEW;
330 $vals[
'minor'] = (bool)$recentChangeInfo[
'rc_minor'];
334 if ( $this->fld_sizes ) {
335 $vals[
'oldlen'] = (int)$recentChangeInfo[
'rc_old_len'];
336 $vals[
'newlen'] = (int)$recentChangeInfo[
'rc_new_len'];
340 if ( $this->fld_timestamp ) {
341 $vals[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $recentChangeInfo[
'rc_timestamp'] );
344 if ( $this->fld_notificationtimestamp ) {
351 if ( $this->fld_comment || $this->fld_parsedcomment ) {
352 if ( $recentChangeInfo[
'rc_deleted'] & RevisionRecord::DELETED_COMMENT ) {
353 $vals[
'commenthidden'] =
true;
356 if ( RevisionRecord::userCanBitfield(
357 $recentChangeInfo[
'rc_deleted'],
358 RevisionRecord::DELETED_COMMENT,
361 $comment = $this->commentStore->getComment(
'rc_comment', $recentChangeInfo )->text;
362 if ( $this->fld_comment ) {
363 $vals[
'comment'] = $comment;
366 if ( $this->fld_parsedcomment ) {
373 if ( $this->fld_patrol ) {
379 if ( $this->fld_loginfo && $recentChangeInfo[
'rc_type'] ==
RC_LOG ) {
381 $vals[
'actionhidden'] =
true;
385 $recentChangeInfo[
'rc_deleted'],
389 $vals[
'logid'] = (int)$recentChangeInfo[
'rc_logid'];
390 $vals[
'logtype'] = $recentChangeInfo[
'rc_log_type'];
391 $vals[
'logaction'] = $recentChangeInfo[
'rc_log_action'];
396 if ( $this->fld_tags ) {
397 if ( $recentChangeInfo[
'rc_tags'] ) {
398 $tags = explode(
',', $recentChangeInfo[
'rc_tags'] );
400 $vals[
'tags'] = $tags;
406 if ( $anyHidden && ( $recentChangeInfo[
'rc_deleted'] & RevisionRecord::DELETED_RESTRICTED ) ) {
407 $vals[
'suppressed'] =
true;
410 Hooks::run(
'ApiQueryWatchlistExtractOutputData', [
411 $this, $watchedItem, $recentChangeInfo, &$vals
466 'notificationtimestamp',
509 'action=query&list=watchlist'
510 =>
'apihelp-query+watchlist-example-simple',
511 'action=query&list=watchlist&wlprop=ids|title|timestamp|user|comment'
512 =>
'apihelp-query+watchlist-example-props',
513 'action=query&list=watchlist&wlallrev=&wlprop=ids|title|timestamp|user|comment'
514 =>
'apihelp-query+watchlist-example-allrev',
515 'action=query&generator=watchlist&prop=info'
516 =>
'apihelp-query+watchlist-example-generator',
517 'action=query&generator=watchlist&gwlallrev=&prop=revisions&rvprop=timestamp|user'
518 =>
'apihelp-query+watchlist-example-generator-rev',
519 'action=query&list=watchlist&wlowner=Example&wltoken=123ABC'
520 =>
'apihelp-query+watchlist-example-wlowner',
525 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watchlist';