36 parent::__construct( $query, $moduleName,
'wl' );
44 $this->
run( $resultPageSet );
57 private function run( $resultPageSet = null ) {
65 if ( !is_null(
$params[
'prop'] ) && is_null( $resultPageSet ) ) {
66 $prop = array_flip(
$params[
'prop'] );
68 $this->fld_ids = isset( $prop[
'ids'] );
69 $this->fld_title = isset( $prop[
'title'] );
70 $this->fld_flags = isset( $prop[
'flags'] );
71 $this->fld_user = isset( $prop[
'user'] );
72 $this->fld_userid = isset( $prop[
'userid'] );
73 $this->fld_comment = isset( $prop[
'comment'] );
74 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
75 $this->fld_timestamp = isset( $prop[
'timestamp'] );
76 $this->fld_sizes = isset( $prop[
'sizes'] );
77 $this->fld_patrol = isset( $prop[
'patrol'] );
78 $this->fld_notificationtimestamp = isset( $prop[
'notificationtimestamp'] );
79 $this->fld_loginfo = isset( $prop[
'loginfo'] );
81 if ( $this->fld_patrol ) {
82 if ( !
$user->useRCPatrol() && !
$user->useNPPatrol() ) {
83 $this->
dieUsage(
'patrol property is not available',
'patrol' );
97 if ( is_null( $resultPageSet ) ) {
104 $this->
addFieldsIf( [
'rc_type',
'rc_minor',
'rc_bot' ], $this->fld_flags );
105 $this->
addFieldsIf(
'rc_user', $this->fld_user || $this->fld_userid );
106 $this->
addFieldsIf(
'rc_user_text', $this->fld_user );
107 $this->
addFieldsIf(
'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
108 $this->
addFieldsIf( [
'rc_patrolled',
'rc_log_type' ], $this->fld_patrol );
109 $this->
addFieldsIf( [
'rc_old_len',
'rc_new_len' ], $this->fld_sizes );
110 $this->
addFieldsIf(
'wl_notificationtimestamp', $this->fld_notificationtimestamp );
112 [
'rc_logid',
'rc_log_type',
'rc_log_action',
'rc_params' ],
115 } elseif (
$params[
'allrev'] ) {
126 $userId = $wlowner->getId();
129 'wl_user' => $userId,
130 'wl_namespace=rc_namespace',
135 $db = $this->
getDB();
142 if ( !is_null(
$params[
'continue'] ) ) {
143 $cont = explode(
'|',
$params[
'continue'] );
145 $op = (
$params[
'dir'] ===
'newer' ?
'>' :
'<' );
146 $continueTimestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
147 $continueId = (int)$cont[1];
149 $this->
addWhere(
"rc_timestamp $op $continueTimestamp OR " .
150 "(rc_timestamp = $continueTimestamp AND " .
151 "rc_id $op= $continueId)"
159 $this->
addJoinConds( [
'page' => [
'LEFT JOIN',
'rc_cur_id=page_id' ] ] );
160 $this->
addWhere(
'rc_this_oldid=page_latest OR rc_type=' .
RC_LOG );
163 if ( !is_null(
$params[
'show'] ) ) {
164 $show = array_flip(
$params[
'show'] );
167 if ( ( isset( $show[
'minor'] ) && isset( $show[
'!minor'] ) )
168 || ( isset( $show[
'bot'] ) && isset( $show[
'!bot'] ) )
169 || ( isset( $show[
'anon'] ) && isset( $show[
'!anon'] ) )
170 || ( isset( $show[
'patrolled'] ) && isset( $show[
'!patrolled'] ) )
171 || ( isset( $show[
'unread'] ) && isset( $show[
'!unread'] ) )
177 if ( isset( $show[
'patrolled'] ) || isset( $show[
'!patrolled'] ) ) {
178 if ( !
$user->useRCPatrol() && !
$user->useNPPatrol() ) {
180 'You need the patrol right to request the patrolled flag',
187 $this->
addWhereIf(
'rc_minor = 0', isset( $show[
'!minor'] ) );
188 $this->
addWhereIf(
'rc_minor != 0', isset( $show[
'minor'] ) );
189 $this->
addWhereIf(
'rc_bot = 0', isset( $show[
'!bot'] ) );
190 $this->
addWhereIf(
'rc_bot != 0', isset( $show[
'bot'] ) );
191 $this->
addWhereIf(
'rc_user = 0', isset( $show[
'anon'] ) );
192 $this->
addWhereIf(
'rc_user != 0', isset( $show[
'!anon'] ) );
193 $this->
addWhereIf(
'rc_patrolled = 0', isset( $show[
'!patrolled'] ) );
194 $this->
addWhereIf(
'rc_patrolled != 0', isset( $show[
'patrolled'] ) );
195 $this->
addWhereIf(
'rc_timestamp >= wl_notificationtimestamp', isset( $show[
'unread'] ) );
197 'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp',
198 isset( $show[
'!unread'] )
202 if ( !is_null(
$params[
'type'] ) ) {
210 if ( !is_null(
$params[
'user'] ) && !is_null(
$params[
'excludeuser'] ) ) {
211 $this->
dieUsage(
'user and excludeuser cannot be used together',
'user-excludeuser' );
213 if ( !is_null(
$params[
'user'] ) ) {
216 if ( !is_null(
$params[
'excludeuser'] ) ) {
217 $this->
addWhere(
'rc_user_text != ' . $db->addQuotes(
$params[
'excludeuser'] ) );
223 !isset(
$params[
'start'] ) && !isset(
$params[
'end'] ) && $db->getType() ==
'mysql'
227 if ( !is_null(
$params[
'user'] ) || !is_null(
$params[
'excludeuser'] ) ) {
228 if ( !
$user->isAllowed(
'deletedhistory' ) ) {
230 } elseif ( !
$user->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
236 $this->
addWhere( $this->
getDB()->bitAnd(
'rc_deleted', $bitmask ) .
" != $bitmask" );
242 if ( !
$user->isAllowed(
'deletedhistory' ) ) {
244 } elseif ( !
$user->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
252 $this->
getDB()->bitAnd(
'rc_deleted', $bitmask ) .
" != $bitmask",
262 foreach (
$res as $row ) {
270 if ( is_null( $resultPageSet ) ) {
279 $ids[] = intval( $row->rc_this_oldid );
281 $ids[] = intval( $row->rc_cur_id );
286 if ( is_null( $resultPageSet ) ) {
291 } elseif (
$params[
'allrev'] ) {
292 $resultPageSet->populateFromRevisionIDs( $ids );
294 $resultPageSet->populateFromPageIDs( $ids );
305 $type = intval( $row->rc_type );
310 if ( $this->fld_title || $this->fld_ids ) {
313 $vals[
'actionhidden'] =
true;
319 if ( $this->fld_title ) {
322 if ( $this->fld_ids ) {
323 $vals[
'pageid'] = intval( $row->rc_cur_id );
324 $vals[
'revid'] = intval( $row->rc_this_oldid );
325 $vals[
'old_revid'] = intval( $row->rc_last_oldid );
331 if ( $this->fld_user || $this->fld_userid ) {
333 $vals[
'userhidden'] =
true;
337 if ( $this->fld_userid ) {
338 $vals[
'userid'] = (int)$row->rc_user;
340 $vals[
'user'] = (
int)$row->rc_user;
343 if ( $this->fld_user ) {
344 $vals[
'user'] = $row->rc_user_text;
347 if ( !$row->rc_user ) {
348 $vals[
'anon'] =
true;
354 if ( $this->fld_flags ) {
355 $vals[
'bot'] = (bool)$row->rc_bot;
356 $vals[
'new'] = $row->rc_type ==
RC_NEW;
357 $vals[
'minor'] = (
bool)$row->rc_minor;
361 if ( $this->fld_sizes ) {
362 $vals[
'oldlen'] = intval( $row->rc_old_len );
363 $vals[
'newlen'] = intval( $row->rc_new_len );
367 if ( $this->fld_timestamp ) {
371 if ( $this->fld_notificationtimestamp ) {
372 $vals[
'notificationtimestamp'] = ( $row->wl_notificationtimestamp == null )
378 if ( $this->fld_comment || $this->fld_parsedcomment ) {
380 $vals[
'commenthidden'] =
true;
384 if ( $this->fld_comment && isset( $row->rc_comment ) ) {
385 $vals[
'comment'] = $row->rc_comment;
388 if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
395 if ( $this->fld_patrol ) {
396 $vals[
'patrolled'] = $row->rc_patrolled == 1;
400 if ( $this->fld_loginfo && $row->rc_type ==
RC_LOG ) {
402 $vals[
'actionhidden'] =
true;
406 $vals[
'logid'] = intval( $row->rc_logid );
407 $vals[
'logtype'] = $row->rc_log_type;
408 $vals[
'logaction'] = $row->rc_log_action;
414 $vals[
'suppressed'] =
true;
469 '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/API:Watchlist';
select($method, $extraQuery=[])
Execute a SELECT query based on the values in the internal arrays.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below...
__construct(ApiQuery $query, $moduleName)
getDB()
Get the Query database connection (read-only)
const LIMIT_BIG2
Fast query, apihighlimits limit.
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
getResult()
Get the result object.
static getChangeTypes()
Get an array of all change types.
getWatchlistUser($params)
Gets the user for whom to get the watchlist.
addWhereFld($field, $value)
Equivalent to addWhere(array($field => $value))
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
const LIMIT_BIG1
Fast query, standard limit.
addWhereRange($field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction...
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
extractRequestParams($parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user...
$fld_notificationtimestamp
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
addTimestampWhereRange($field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
setContinueEnumParameter($paramName, $paramValue)
Overridden to set the generator param if in generator mode.
addWhere($value)
Add a set of WHERE clauses to the internal array.
addJoinConds($join_conds)
Add a set of JOIN conditions to the internal array.
executeGenerator($resultPageSet)
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
addWhereIf($value, $condition)
Same as addWhere(), but add the WHERE clauses only if a condition is met.
addOption($name, $value=null)
Add an option such as LIMIT or USE INDEX.
namespace and then decline to actually register it file or subcat img or subcat $title
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right, for PARAM_TYPE 'limit'.
This is the main query class.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
dieContinueUsageIf($condition)
Die with the $prefix.
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...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter...
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
This query action allows clients to retrieve a list of recently modified pages that are part of the l...
static parseFromRCType($rcType)
Parsing RC_* constants to human-readable test.
const PARAM_SENSITIVE
(boolean) Is the parameter sensitive? Note 'password'-type fields are always sensitive regardless of ...
addFieldsIf($value, $condition)
Same as addFields(), but add the fields only if a condition is met.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static userCanBitfield($bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row, if it's marked as deleted.
addFields($value)
Add a set of fields to select to the internal array.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
dieUsage($description, $errorCode, $httpRespCode=0, $extradata=null)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
static userCanBitfield($bitfield, $field, User $user=null, Title $title=null)
Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
static dieDebug($method, $message)
Internal code errors should be reported with this method.
static isUnpatrolled($rc, User $user)
static addTitleInfo(&$arr, $title, $prefix= '')
Add information (title and namespace) about a Title object to a result array.
static parseToRCType($type)
Parsing text to RC_* constants.
getUser()
Get the User object.
addTables($tables, $alias=null)
Add a set of tables to the internal array.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
dieUsageMsg($error)
Output the error message related to a certain array.
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
selectNamedDB($name, $db, $groups)
Selects the query database connection with the given name.