70 parent::__construct( $query, $moduleName,
'wl' );
83 $this->
run( $resultPageSet );
99 private function run( $resultPageSet =
null ) {
107 if ( $params[
'prop'] !==
null && $resultPageSet ===
null ) {
108 $prop = array_fill_keys( $params[
'prop'],
true );
110 $this->fld_ids = isset( $prop[
'ids'] );
111 $this->fld_title = isset( $prop[
'title'] );
112 $this->fld_flags = isset( $prop[
'flags'] );
113 $this->fld_user = isset( $prop[
'user'] );
114 $this->fld_userid = isset( $prop[
'userid'] );
115 $this->fld_comment = isset( $prop[
'comment'] );
116 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
117 $this->fld_timestamp = isset( $prop[
'timestamp'] );
118 $this->fld_sizes = isset( $prop[
'sizes'] );
119 $this->fld_patrol = isset( $prop[
'patrol'] );
120 $this->fld_notificationtimestamp = isset( $prop[
'notificationtimestamp'] );
121 $this->fld_loginfo = isset( $prop[
'loginfo'] );
122 $this->fld_tags = isset( $prop[
'tags'] );
123 $this->fld_expiry = isset( $prop[
'expiry'] );
125 if ( $this->fld_patrol && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
126 $this->
dieWithError(
'apierror-permissiondenied-patrolflag',
'patrol' );
131 'dir' => $params[
'dir'] ===
'older'
136 if ( $resultPageSet ===
null ) {
139 $options[
'usedInGenerator'] =
true;
142 if ( $params[
'start'] ) {
143 $options[
'start'] = $params[
'start'];
145 if ( $params[
'end'] ) {
146 $options[
'end'] = $params[
'end'];
150 if ( $params[
'continue'] !==
null ) {
151 $cont = explode(
'|', $params[
'continue'] );
153 $continueTimestamp = $cont[0];
154 $continueId = (int)$cont[1];
156 $startFrom = [ $continueTimestamp, $continueId ];
159 if ( $wlowner !== $user ) {
160 $options[
'watchlistOwner'] = $wlowner;
161 $options[
'watchlistOwnerToken'] = $params[
'token'];
164 if ( $params[
'namespace'] !==
null ) {
165 $options[
'namespaceIds'] = $params[
'namespace'];
168 if ( $params[
'allrev'] ) {
169 $options[
'allRevisions'] =
true;
172 if ( $params[
'show'] !==
null ) {
173 $show = array_fill_keys( $params[
'show'],
true );
184 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
185 $this->
dieWithError(
'apierror-permissiondenied-patrolflag',
'permissiondenied' );
189 $options[
'filters'] = array_keys( $show );
192 if ( $params[
'type'] !==
null ) {
196 $options[
'rcTypes'] = $rcTypes;
198 }
catch ( Exception $e ) {
204 if ( $params[
'user'] !==
null ) {
205 $options[
'onlyByUser'] = $params[
'user'];
207 if ( $params[
'excludeuser'] !==
null ) {
208 $options[
'notByUser'] = $params[
'excludeuser'];
211 $options[
'limit'] = $params[
'limit'];
213 $this->
getHookRunner()->onApiQueryWatchlistPrepareWatchedItemQueryServiceOptions(
214 $this, $params, $options );
217 $items = $this->watchedItemQueryService->getWatchedItemsWithRecentChangeInfo( $wlowner, $options, $startFrom );
220 if ( $items !== [] && $resultPageSet ===
null && $this->fld_title &&
221 $this->contentLanguage->needsGenderDistinction()
224 foreach ( $items as list( $watchedItem, $recentChangeInfo ) ) {
226 $linkTarget = $watchedItem->getTarget();
227 if ( $this->namespaceInfo->hasGenderDistinction( $linkTarget->getNamespace() ) ) {
228 $usernames[] = $linkTarget->getText();
231 if ( $usernames !== [] ) {
232 $this->genderCache->doQuery( $usernames, __METHOD__ );
236 foreach ( $items as list( $watchedItem, $recentChangeInfo ) ) {
238 if ( $resultPageSet ===
null ) {
242 $startFrom = [ $recentChangeInfo[
'rc_timestamp'], $recentChangeInfo[
'rc_id'] ];
245 } elseif ( $params[
'allrev'] ) {
246 $ids[] = (int)$recentChangeInfo[
'rc_this_oldid'];
248 $ids[] = (int)$recentChangeInfo[
'rc_cur_id'];
252 if ( $startFrom !==
null ) {
256 if ( $resultPageSet ===
null ) {
261 } elseif ( $params[
'allrev'] ) {
262 $resultPageSet->populateFromRevisionIDs( $ids );
264 $resultPageSet->populateFromPageIDs( $ids );
270 if ( $this->fld_flags ) {
273 if ( $this->fld_user || $this->fld_userid || $this->fld_loginfo ) {
276 if ( $this->fld_user || $this->fld_loginfo ) {
279 if ( $this->fld_comment || $this->fld_parsedcomment ) {
282 if ( $this->fld_patrol ) {
286 if ( $this->fld_sizes ) {
289 if ( $this->fld_loginfo ) {
292 if ( $this->fld_tags ) {
295 return $includeFields;
327 $type = (int)$recentChangeInfo[
'rc_type'];
332 if ( $this->fld_title || $this->fld_ids ) {
335 $vals[
'actionhidden'] =
true;
340 $recentChangeInfo[
'rc_deleted'],
345 if ( $this->fld_title ) {
349 if ( $this->fld_ids ) {
350 $vals[
'pageid'] = (int)$recentChangeInfo[
'rc_cur_id'];
351 $vals[
'revid'] = (int)$recentChangeInfo[
'rc_this_oldid'];
352 $vals[
'old_revid'] = (int)$recentChangeInfo[
'rc_last_oldid'];
358 if ( $this->fld_user || $this->fld_userid ) {
359 if ( $recentChangeInfo[
'rc_deleted'] & RevisionRecord::DELETED_USER ) {
360 $vals[
'userhidden'] =
true;
363 if ( RevisionRecord::userCanBitfield(
364 $recentChangeInfo[
'rc_deleted'],
365 RevisionRecord::DELETED_USER,
368 if ( $this->fld_userid ) {
369 $vals[
'userid'] = (int)$recentChangeInfo[
'rc_user'];
371 $vals[
'user'] = (int)$recentChangeInfo[
'rc_user'];
374 if ( $this->fld_user ) {
375 $vals[
'user'] = $recentChangeInfo[
'rc_user_text'];
378 $vals[
'anon'] = !$recentChangeInfo[
'rc_user'];
383 if ( $this->fld_flags ) {
384 $vals[
'bot'] = (bool)$recentChangeInfo[
'rc_bot'];
385 $vals[
'new'] = $recentChangeInfo[
'rc_type'] ==
RC_NEW;
386 $vals[
'minor'] = (bool)$recentChangeInfo[
'rc_minor'];
390 if ( $this->fld_sizes ) {
391 $vals[
'oldlen'] = (int)$recentChangeInfo[
'rc_old_len'];
392 $vals[
'newlen'] = (int)$recentChangeInfo[
'rc_new_len'];
396 if ( $this->fld_timestamp ) {
397 $vals[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $recentChangeInfo[
'rc_timestamp'] );
400 if ( $this->fld_notificationtimestamp ) {
407 if ( $this->fld_comment || $this->fld_parsedcomment ) {
408 if ( $recentChangeInfo[
'rc_deleted'] & RevisionRecord::DELETED_COMMENT ) {
409 $vals[
'commenthidden'] =
true;
412 if ( RevisionRecord::userCanBitfield(
413 $recentChangeInfo[
'rc_deleted'],
414 RevisionRecord::DELETED_COMMENT,
417 $comment = $this->commentStore->getComment(
'rc_comment', $recentChangeInfo )->text;
418 if ( $this->fld_comment ) {
419 $vals[
'comment'] = $comment;
422 if ( $this->fld_parsedcomment ) {
429 if ( $this->fld_patrol ) {
435 if ( $this->fld_loginfo && $recentChangeInfo[
'rc_type'] ==
RC_LOG ) {
437 $vals[
'actionhidden'] =
true;
441 $recentChangeInfo[
'rc_deleted'],
445 $vals[
'logid'] = (int)$recentChangeInfo[
'rc_logid'];
446 $vals[
'logtype'] = $recentChangeInfo[
'rc_log_type'];
447 $vals[
'logaction'] = $recentChangeInfo[
'rc_log_action'];
450 $vals[
'logparams'] = $logFormatter->formatParametersForApi();
451 $vals[
'logdisplay'] = $logFormatter->getActionText();
455 if ( $this->fld_tags ) {
456 if ( $recentChangeInfo[
'rc_tags'] ) {
457 $tags = explode(
',', $recentChangeInfo[
'rc_tags'] );
459 $vals[
'tags'] = $tags;
465 if ( $this->fld_expiry ) {
467 $expiry = $watchedItem->
getExpiry( TS_ISO_8601 );
468 $vals[
'expiry'] = ( $expiry ?? false );
471 if ( $anyHidden && ( $recentChangeInfo[
'rc_deleted'] & RevisionRecord::DELETED_RESTRICTED ) ) {
472 $vals[
'suppressed'] =
true;
475 $this->
getHookRunner()->onApiQueryWatchlistExtractOutputData(
476 $this, $watchedItem, $recentChangeInfo, $vals );
485 ParamValidator::PARAM_TYPE =>
'timestamp'
488 ParamValidator::PARAM_TYPE =>
'timestamp'
491 ParamValidator::PARAM_ISMULTI =>
true,
492 ParamValidator::PARAM_TYPE =>
'namespace'
495 ParamValidator::PARAM_TYPE =>
'user',
496 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
499 ParamValidator::PARAM_TYPE =>
'user',
500 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
503 ParamValidator::PARAM_DEFAULT =>
'older',
504 ParamValidator::PARAM_TYPE => [
511 ParamValidator::PARAM_DEFAULT => 10,
512 ParamValidator::PARAM_TYPE =>
'limit',
513 IntegerDef::PARAM_MIN => 1,
518 ParamValidator::PARAM_ISMULTI =>
true,
519 ParamValidator::PARAM_DEFAULT =>
'ids|title|flags',
521 ParamValidator::PARAM_TYPE => [
532 'notificationtimestamp',
539 ParamValidator::PARAM_ISMULTI =>
true,
540 ParamValidator::PARAM_TYPE => [
556 ParamValidator::PARAM_DEFAULT =>
'edit|new|log|categorize',
557 ParamValidator::PARAM_ISMULTI =>
true,
562 ParamValidator::PARAM_TYPE =>
'user',
563 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
566 ParamValidator::PARAM_TYPE =>
'string',
567 ParamValidator::PARAM_SENSITIVE =>
true,
577 'action=query&list=watchlist'
578 =>
'apihelp-query+watchlist-example-simple',
579 'action=query&list=watchlist&wlprop=ids|title|timestamp|user|comment'
580 =>
'apihelp-query+watchlist-example-props',
581 'action=query&list=watchlist&wlprop=ids|title|timestamp|user|comment|expiry'
582 =>
'apihelp-query+watchlist-example-expiry',
583 'action=query&list=watchlist&wlallrev=&wlprop=ids|title|timestamp|user|comment'
584 =>
'apihelp-query+watchlist-example-allrev',
585 'action=query&generator=watchlist&prop=info'
586 =>
'apihelp-query+watchlist-example-generator',
587 'action=query&generator=watchlist&gwlallrev=&prop=revisions&rvprop=timestamp|user'
588 =>
'apihelp-query+watchlist-example-generator-rev',
589 'action=query&list=watchlist&wlowner=Example&wltoken=123ABC'
590 =>
'apihelp-query+watchlist-example-wlowner',
595 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watchlist';
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
getWatchlistUser( $params)
Gets the user for whom to get the watchlist.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
const LIMIT_BIG1
Fast query, standard limit.
requireMaxOneParameter( $params,... $required)
Die if more than one of a certain set of parameters is set and not false.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
getHookRunner()
Get an ApiHookRunner for running core API hooks.
selectNamedDB( $name, $db, $groups)
Selects the query database connection with the given name.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
This query action allows clients to retrieve a list of recently modified pages that are part of the l...
__construct(ApiQuery $query, $moduleName, CommentStore $commentStore, WatchedItemQueryService $watchedItemQueryService, Language $contentLanguage, NamespaceInfo $namespaceInfo, GenderCache $genderCache)
Language $contentLanguage
run( $resultPageSet=null)
$fld_notificationtimestamp
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
extractOutputData(WatchedItem $watchedItem, array $recentChangeInfo)
showParamsConflicting(array $show)
CommentStore $commentStore
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
NamespaceInfo $namespaceInfo
getExamplesMessages()
Returns usage examples for this module.
getHelpUrls()
Return links to more detailed help pages about the module.
executeGenerator( $resultPageSet)
Execute this module as a generator.
WatchedItemQueryService $watchedItemQueryService
This is the main query class.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static isUnpatrolled( $rc, User $user)
Caches user genders when needed to use correct namespace aliases.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
static userCanBitfield( $bitfield, $field, Authority $performer)
Determine if the current user is allowed to view a particular field of this log row,...
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
static parseToRCType( $type)
Parsing text to RC_* constants.
static getChangeTypes()
Get an array of all change types.
static parseFromRCType( $rcType)
Parsing RC_* constants to human-readable test.
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
static castFromPageIdentity(?PageIdentity $pageIdentity)
Return a Title for a given PageIdentity.
const INCLUDE_AUTOPATROL_INFO
const FILTER_NOT_AUTOPATROLLED
const INCLUDE_PATROL_INFO
const FILTER_AUTOPATROLLED
const FILTER_NOT_PATROLLED
Representation of a pair of user and title for watchlist entries.
getExpiry(?int $style=TS_MW)
When the watched item will expire.
getNotificationTimestamp()
Get the notification timestamp of this entry.