38 parent::__construct(
$query, $moduleName,
'wl' );
46 $this->
run( $resultPageSet );
59 private function run( $resultPageSet =
null ) {
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 ) {
89 $this->commentStore = CommentStore::getStore();
94 'dir' =>
$params[
'dir'] ===
'older'
95 ? WatchedItemQueryService::DIR_OLDER
96 : WatchedItemQueryService::DIR_NEWER,
99 if (
is_null( $resultPageSet ) ) {
114 $cont = explode(
'|',
$params[
'continue'] );
116 $continueTimestamp = $cont[0];
117 $continueId = (
int)$cont[1];
122 if ( $wlowner !== $user ) {
144 if (
isset( $show[WatchedItemQueryService::FILTER_PATROLLED] )
145 ||
isset( $show[WatchedItemQueryService::FILTER_NOT_PATROLLED] )
147 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
148 $this->
dieWithError(
'apierror-permissiondenied-patrolflag',
'permissiondenied' );
157 $rcTypes = RecentChange::parseToRCType(
$params[
'type'] );
161 }
catch ( Exception
$e ) {
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'] ];
194 $ids[] = (
int)$recentChangeInfo[
'rc_this_oldid'];
196 $ids[] = (
int)$recentChangeInfo[
'rc_cur_id'];
200 if ( $startFrom !==
null ) {
204 if (
is_null( $resultPageSet ) ) {
210 $resultPageSet->populateFromRevisionIDs( $ids );
212 $resultPageSet->populateFromPageIDs( $ids );
218 if ( $this->fld_flags ) {
219 $includeFields[] = WatchedItemQueryService::INCLUDE_FLAGS;
221 if ( $this->fld_user || $this->fld_userid ) {
222 $includeFields[] = WatchedItemQueryService::INCLUDE_USER_ID;
224 if ( $this->fld_user ) {
225 $includeFields[] = WatchedItemQueryService::INCLUDE_USER;
227 if ( $this->fld_comment || $this->fld_parsedcomment ) {
228 $includeFields[] = WatchedItemQueryService::INCLUDE_COMMENT;
230 if ( $this->fld_patrol ) {
231 $includeFields[] = WatchedItemQueryService::INCLUDE_PATROL_INFO;
232 $includeFields[] = WatchedItemQueryService::INCLUDE_AUTOPATROL_INFO;
234 if ( $this->fld_sizes ) {
235 $includeFields[] = WatchedItemQueryService::INCLUDE_SIZES;
237 if ( $this->fld_loginfo ) {
238 $includeFields[] = WatchedItemQueryService::INCLUDE_LOG_INFO;
240 if ( $this->fld_tags ) {
241 $includeFields[] = WatchedItemQueryService::INCLUDE_TAGS;
247 return (
isset( $show[WatchedItemQueryService::FILTER_MINOR] )
248 &&
isset( $show[WatchedItemQueryService::FILTER_NOT_MINOR] ) )
249 || (
isset( $show[WatchedItemQueryService::FILTER_BOT] )
250 &&
isset( $show[WatchedItemQueryService::FILTER_NOT_BOT] ) )
251 || (
isset( $show[WatchedItemQueryService::FILTER_ANON] )
252 &&
isset( $show[WatchedItemQueryService::FILTER_NOT_ANON] ) )
253 || (
isset( $show[WatchedItemQueryService::FILTER_PATROLLED] )
254 &&
isset( $show[WatchedItemQueryService::FILTER_NOT_PATROLLED] ) )
255 || (
isset( $show[WatchedItemQueryService::FILTER_AUTOPATROLLED] )
256 &&
isset( $show[WatchedItemQueryService::FILTER_NOT_AUTOPATROLLED] ) )
257 || (
isset( $show[WatchedItemQueryService::FILTER_AUTOPATROLLED] )
258 &&
isset( $show[WatchedItemQueryService::FILTER_NOT_PATROLLED] ) )
259 || (
isset( $show[WatchedItemQueryService::FILTER_UNREAD] )
260 &&
isset( $show[WatchedItemQueryService::FILTER_NOT_UNREAD] ) );
265 $title = Title::newFromLinkTarget( $watchedItem->getLinkTarget() );
270 $type = (
int)$recentChangeInfo[
'rc_type'];
271 $vals[
'type'] = RecentChange::parseFromRCType(
$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 ) {
345 $vals[
'notificationtimestamp'] = ( $watchedItem->getNotificationTimestamp() ==
null )
347 :
wfTimestamp( TS_ISO_8601, $watchedItem->getNotificationTimestamp() );
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 ) {
374 $vals[
'patrolled'] = $recentChangeInfo[
'rc_patrolled'] != RecentChange::PRC_UNPATROLLED;
376 $vals[
'autopatrolled'] = $recentChangeInfo[
'rc_patrolled'] == RecentChange::PRC_AUTOPATROLLED;
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',
474 WatchedItemQueryService::FILTER_MINOR,
475 WatchedItemQueryService::FILTER_NOT_MINOR,
476 WatchedItemQueryService::FILTER_BOT,
477 WatchedItemQueryService::FILTER_NOT_BOT,
478 WatchedItemQueryService::FILTER_ANON,
479 WatchedItemQueryService::FILTER_NOT_ANON,
480 WatchedItemQueryService::FILTER_PATROLLED,
481 WatchedItemQueryService::FILTER_NOT_PATROLLED,
482 WatchedItemQueryService::FILTER_AUTOPATROLLED,
483 WatchedItemQueryService::FILTER_NOT_AUTOPATROLLED,
484 WatchedItemQueryService::FILTER_UNREAD,
485 WatchedItemQueryService::FILTER_NOT_UNREAD,
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';
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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.
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.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))