37 parent::__construct(
$query, $moduleName,
'wl' );
45 $this->
run( $resultPageSet );
58 private function run( $resultPageSet =
null ) {
66 if ( !is_null(
$params[
'prop'] ) && is_null( $resultPageSet ) ) {
67 $prop = array_flip(
$params[
'prop'] );
69 $this->fld_ids = isset( $prop[
'ids'] );
70 $this->fld_title = isset( $prop[
'title'] );
71 $this->fld_flags = isset( $prop[
'flags'] );
72 $this->fld_user = isset( $prop[
'user'] );
73 $this->fld_userid = isset( $prop[
'userid'] );
74 $this->fld_comment = isset( $prop[
'comment'] );
75 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
76 $this->fld_timestamp = isset( $prop[
'timestamp'] );
77 $this->fld_sizes = isset( $prop[
'sizes'] );
78 $this->fld_patrol = isset( $prop[
'patrol'] );
79 $this->fld_notificationtimestamp = isset( $prop[
'notificationtimestamp'] );
80 $this->fld_loginfo = isset( $prop[
'loginfo'] );
81 $this->fld_tags = isset( $prop[
'tags'] );
83 if ( $this->fld_patrol ) {
84 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
85 $this->
dieWithError(
'apierror-permissiondenied-patrolflag',
'patrol' );
89 if ( $this->fld_comment || $this->fld_parsedcomment ) {
90 $this->commentStore = CommentStore::getStore();
95 'dir' =>
$params[
'dir'] ===
'older'
96 ? WatchedItemQueryService::DIR_OLDER
97 : WatchedItemQueryService::DIR_NEWER,
100 if ( is_null( $resultPageSet ) ) {
114 if ( !is_null(
$params[
'continue'] ) ) {
115 $cont = explode(
'|',
$params[
'continue'] );
117 $continueTimestamp = $cont[0];
118 $continueId = (int)$cont[1];
120 $startFrom = [ $continueTimestamp, $continueId ];
123 if ( $wlowner !== $user ) {
124 $options[
'watchlistOwner'] = $wlowner;
128 if ( !is_null(
$params[
'namespace'] ) ) {
136 if ( !is_null(
$params[
'show'] ) ) {
137 $show = array_flip(
$params[
'show'] );
145 if ( isset( $show[WatchedItemQueryService::FILTER_PATROLLED] )
146 || isset( $show[WatchedItemQueryService::FILTER_NOT_PATROLLED] )
148 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
149 $this->
dieWithError(
'apierror-permissiondenied-patrolflag',
'permissiondenied' );
153 $options[
'filters'] = array_keys( $show );
156 if ( !is_null(
$params[
'type'] ) ) {
158 $rcTypes = RecentChange::parseToRCType(
$params[
'type'] );
162 }
catch ( Exception
$e ) {
168 if ( !is_null(
$params[
'user'] ) ) {
171 if ( !is_null(
$params[
'excludeuser'] ) ) {
177 Hooks::run(
'ApiQueryWatchlistPrepareWatchedItemQueryServiceOptions', [
183 $watchedItemQuery = MediaWikiServices::getInstance()->getWatchedItemQueryService();
184 $items = $watchedItemQuery->getWatchedItemsWithRecentChangeInfo( $wlowner,
$options, $startFrom );
186 foreach ( $items as
list( $watchedItem, $recentChangeInfo ) ) {
188 if ( is_null( $resultPageSet ) ) {
192 $startFrom = [ $recentChangeInfo[
'rc_timestamp'], $recentChangeInfo[
'rc_id'] ];
197 $ids[] = intval( $recentChangeInfo[
'rc_this_oldid'] );
199 $ids[] = intval( $recentChangeInfo[
'rc_cur_id'] );
204 if ( $startFrom !==
null ) {
208 if ( is_null( $resultPageSet ) ) {
213 } elseif (
$params[
'allrev'] ) {
214 $resultPageSet->populateFromRevisionIDs( $ids );
216 $resultPageSet->populateFromPageIDs( $ids );
222 if ( $this->fld_flags ) {
223 $includeFields[] = WatchedItemQueryService::INCLUDE_FLAGS;
225 if ( $this->fld_user || $this->fld_userid ) {
226 $includeFields[] = WatchedItemQueryService::INCLUDE_USER_ID;
228 if ( $this->fld_user ) {
229 $includeFields[] = WatchedItemQueryService::INCLUDE_USER;
231 if ( $this->fld_comment || $this->fld_parsedcomment ) {
232 $includeFields[] = WatchedItemQueryService::INCLUDE_COMMENT;
234 if ( $this->fld_patrol ) {
235 $includeFields[] = WatchedItemQueryService::INCLUDE_PATROL_INFO;
236 $includeFields[] = WatchedItemQueryService::INCLUDE_AUTOPATROL_INFO;
238 if ( $this->fld_sizes ) {
239 $includeFields[] = WatchedItemQueryService::INCLUDE_SIZES;
241 if ( $this->fld_loginfo ) {
242 $includeFields[] = WatchedItemQueryService::INCLUDE_LOG_INFO;
244 if ( $this->fld_tags ) {
245 $includeFields[] = WatchedItemQueryService::INCLUDE_TAGS;
247 return $includeFields;
251 return ( isset( $show[WatchedItemQueryService::FILTER_MINOR] )
252 && isset( $show[WatchedItemQueryService::FILTER_NOT_MINOR] ) )
253 || ( isset( $show[WatchedItemQueryService::FILTER_BOT] )
254 && isset( $show[WatchedItemQueryService::FILTER_NOT_BOT] ) )
255 || ( isset( $show[WatchedItemQueryService::FILTER_ANON] )
256 && isset( $show[WatchedItemQueryService::FILTER_NOT_ANON] ) )
257 || ( isset( $show[WatchedItemQueryService::FILTER_PATROLLED] )
258 && isset( $show[WatchedItemQueryService::FILTER_NOT_PATROLLED] ) )
259 || ( isset( $show[WatchedItemQueryService::FILTER_AUTOPATROLLED] )
260 && isset( $show[WatchedItemQueryService::FILTER_NOT_AUTOPATROLLED] ) )
261 || ( isset( $show[WatchedItemQueryService::FILTER_AUTOPATROLLED] )
262 && isset( $show[WatchedItemQueryService::FILTER_NOT_PATROLLED] ) )
263 || ( isset( $show[WatchedItemQueryService::FILTER_UNREAD] )
264 && isset( $show[WatchedItemQueryService::FILTER_NOT_UNREAD] ) );
269 $title = Title::newFromLinkTarget( $watchedItem->getLinkTarget() );
274 $type = intval( $recentChangeInfo[
'rc_type'] );
275 $vals[
'type'] = RecentChange::parseFromRCType(
$type );
279 if ( $this->fld_title || $this->fld_ids ) {
282 $vals[
'actionhidden'] =
true;
287 $recentChangeInfo[
'rc_deleted'],
292 if ( $this->fld_title ) {
295 if ( $this->fld_ids ) {
296 $vals[
'pageid'] = intval( $recentChangeInfo[
'rc_cur_id'] );
297 $vals[
'revid'] = intval( $recentChangeInfo[
'rc_this_oldid'] );
298 $vals[
'old_revid'] = intval( $recentChangeInfo[
'rc_last_oldid'] );
304 if ( $this->fld_user || $this->fld_userid ) {
305 if ( $recentChangeInfo[
'rc_deleted'] & Revision::DELETED_USER ) {
306 $vals[
'userhidden'] =
true;
309 if ( Revision::userCanBitfield(
310 $recentChangeInfo[
'rc_deleted'],
311 Revision::DELETED_USER,
314 if ( $this->fld_userid ) {
315 $vals[
'userid'] = (int)$recentChangeInfo[
'rc_user'];
317 $vals[
'user'] = (int)$recentChangeInfo[
'rc_user'];
320 if ( $this->fld_user ) {
321 $vals[
'user'] = $recentChangeInfo[
'rc_user_text'];
324 if ( !$recentChangeInfo[
'rc_user'] ) {
325 $vals[
'anon'] =
true;
331 if ( $this->fld_flags ) {
332 $vals[
'bot'] = (bool)$recentChangeInfo[
'rc_bot'];
333 $vals[
'new'] = $recentChangeInfo[
'rc_type'] ==
RC_NEW;
334 $vals[
'minor'] = (bool)$recentChangeInfo[
'rc_minor'];
338 if ( $this->fld_sizes ) {
339 $vals[
'oldlen'] = intval( $recentChangeInfo[
'rc_old_len'] );
340 $vals[
'newlen'] = intval( $recentChangeInfo[
'rc_new_len'] );
344 if ( $this->fld_timestamp ) {
345 $vals[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $recentChangeInfo[
'rc_timestamp'] );
348 if ( $this->fld_notificationtimestamp ) {
349 $vals[
'notificationtimestamp'] = ( $watchedItem->getNotificationTimestamp() == null )
351 :
wfTimestamp( TS_ISO_8601, $watchedItem->getNotificationTimestamp() );
355 if ( $this->fld_comment || $this->fld_parsedcomment ) {
356 if ( $recentChangeInfo[
'rc_deleted'] & Revision::DELETED_COMMENT ) {
357 $vals[
'commenthidden'] =
true;
360 if ( Revision::userCanBitfield(
361 $recentChangeInfo[
'rc_deleted'],
362 Revision::DELETED_COMMENT,
365 $comment = $this->commentStore->getComment(
'rc_comment', $recentChangeInfo )->text;
366 if ( $this->fld_comment ) {
367 $vals[
'comment'] = $comment;
370 if ( $this->fld_parsedcomment ) {
377 if ( $this->fld_patrol ) {
378 $vals[
'patrolled'] = $recentChangeInfo[
'rc_patrolled'] != RecentChange::PRC_UNPATROLLED;
380 $vals[
'autopatrolled'] = $recentChangeInfo[
'rc_patrolled'] == RecentChange::PRC_AUTOPATROLLED;
383 if ( $this->fld_loginfo && $recentChangeInfo[
'rc_type'] ==
RC_LOG ) {
385 $vals[
'actionhidden'] =
true;
389 $recentChangeInfo[
'rc_deleted'],
393 $vals[
'logid'] = intval( $recentChangeInfo[
'rc_logid'] );
394 $vals[
'logtype'] = $recentChangeInfo[
'rc_log_type'];
395 $vals[
'logaction'] = $recentChangeInfo[
'rc_log_action'];
400 if ( $this->fld_tags ) {
401 if ( $recentChangeInfo[
'rc_tags'] ) {
402 $tags = explode(
',', $recentChangeInfo[
'rc_tags'] );
404 $vals[
'tags'] = $tags;
410 if ( $anyHidden && ( $recentChangeInfo[
'rc_deleted'] & Revision::DELETED_RESTRICTED ) ) {
411 $vals[
'suppressed'] =
true;
414 Hooks::run(
'ApiQueryWatchlistExtractOutputData', [
415 $this, $watchedItem, $recentChangeInfo, &$vals
470 'notificationtimestamp',
478 WatchedItemQueryService::FILTER_MINOR,
479 WatchedItemQueryService::FILTER_NOT_MINOR,
480 WatchedItemQueryService::FILTER_BOT,
481 WatchedItemQueryService::FILTER_NOT_BOT,
482 WatchedItemQueryService::FILTER_ANON,
483 WatchedItemQueryService::FILTER_NOT_ANON,
484 WatchedItemQueryService::FILTER_PATROLLED,
485 WatchedItemQueryService::FILTER_NOT_PATROLLED,
486 WatchedItemQueryService::FILTER_AUTOPATROLLED,
487 WatchedItemQueryService::FILTER_NOT_AUTOPATROLLED,
488 WatchedItemQueryService::FILTER_UNREAD,
489 WatchedItemQueryService::FILTER_NOT_UNREAD,
513 'action=query&list=watchlist'
514 =>
'apihelp-query+watchlist-example-simple',
515 'action=query&list=watchlist&wlprop=ids|title|timestamp|user|comment'
516 =>
'apihelp-query+watchlist-example-props',
517 'action=query&list=watchlist&wlallrev=&wlprop=ids|title|timestamp|user|comment'
518 =>
'apihelp-query+watchlist-example-allrev',
519 'action=query&generator=watchlist&prop=info'
520 =>
'apihelp-query+watchlist-example-generator',
521 'action=query&generator=watchlist&gwlallrev=&prop=revisions&rvprop=timestamp|user'
522 =>
'apihelp-query+watchlist-example-generator-rev',
523 'action=query&list=watchlist&wlowner=Example&wltoken=123ABC'
524 =>
'apihelp-query+watchlist-example-wlowner',
529 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watchlist';
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these that in whole or in part contains or is derived from the Program or any part to be licensed as a whole at no charge to all third parties under the terms of this License c If the modified program normally reads commands interactively when run
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
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_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_SENSITIVE
(boolean) Is the parameter sensitive? Note 'password'-type fields are always sensitive regardless of ...
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
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 PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
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.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
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...
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...
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.
__construct(ApiQuery $query, $moduleName)
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)
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, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
Representation of a pair of user and title for watchlist entries.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
returning false will NOT prevent logging $e