Go to the documentation of this file.
40 parent::__construct(
$query, $moduleName,
'rv' );
52 if ( isset( $this->tokenFunctions ) ) {
62 $this->tokenFunctions = [
63 'rollback' => [
'ApiQueryRevisions',
'getRollbackToken' ]
65 Hooks::run(
'APIQueryRevisionsTokens', [ &$this->tokenFunctions ] );
79 if ( !
$wgUser->isAllowed(
'rollback' ) ) {
83 return $wgUser->getEditToken(
'rollback' );
93 $enumRevMode = (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ||
99 $pageCount = $pageSet->getGoodTitleCount();
100 $revCount = $pageSet->getRevisionCount();
103 if ( $revCount === 0 && $pageCount === 0 ) {
107 if ( $revCount > 0 &&
count( $pageSet->getLiveRevisionIDs() ) === 0 ) {
112 if ( $revCount > 0 && $enumRevMode ) {
114 [
'apierror-revisions-nolist', $this->
getModulePrefix() ],
'invalidparammix'
118 if ( $pageCount > 1 && $enumRevMode ) {
120 [
'apierror-revisions-singlepage', $this->
getModulePrefix() ],
'invalidparammix'
126 if ( !$enumRevMode ) {
127 $this->setParsedLimit =
false;
131 $db = $this->
getDB();
132 $this->
addTables( [
'revision',
'page' ] );
134 [
'page' => [
'INNER JOIN', [
'page_id = rev_page' ] ] ]
137 if ( $resultPageSet ===
null ) {
139 $this->token =
$params[
'token'];
141 if ( $this->token !==
null || $pageCount > 0 ) {
146 $this->
addFields( [
'rev_id',
'rev_timestamp',
'rev_page' ] );
149 if ( $this->fld_tags ) {
152 [
'tag_summary' => [
'LEFT JOIN', [
'rev_id=ts_rev_id' ] ] ]
157 if (
$params[
'tag'] !==
null ) {
160 [
'change_tag' => [
'INNER JOIN', [
'rev_id=ct_rev_id' ] ] ]
165 if ( $this->fetchContent ) {
170 foreach ( $pageSet->getGoodTitles()
as $title ) {
184 [
'text' => [
'INNER JOIN', [
'rev_text_id=old_id' ] ] ]
191 if ( $this->fld_user ) {
197 if ( $enumRevMode ) {
208 if (
$params[
'continue'] !==
null ) {
209 $cont = explode(
'|',
$params[
'continue'] );
211 $op = (
$params[
'dir'] ===
'newer' ?
'>' :
'<' );
212 $continueTimestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
213 $continueId = (int)$cont[1];
215 $this->
addWhere(
"rev_timestamp $op $continueTimestamp OR " .
216 "(rev_timestamp = $continueTimestamp AND " .
217 "rev_id $op= $continueId)"
227 $ids = array_keys( $pageSet->getGoodTitles() );
230 if (
$params[
'user'] !==
null ) {
237 } elseif (
$params[
'excludeuser'] !==
null ) {
242 $this->
addWhere(
'rev_user_text != ' .
243 $db->addQuotes(
$params[
'excludeuser'] ) );
246 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
248 if ( !$this->
getUser()->isAllowed(
'deletedhistory' ) ) {
250 } elseif ( !$this->
getUser()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
256 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
259 } elseif ( $revCount > 0 ) {
262 $revs = $pageSet->getLiveRevisionIDs();
265 $this->
addWhereFld(
'rev_id', array_keys( $revs ) );
267 if (
$params[
'continue'] !==
null ) {
270 $this->
addOption(
'ORDER BY',
'rev_id' );
271 } elseif ( $pageCount > 0 ) {
274 $titles = $pageSet->getGoodTitles();
278 $this->
addWhere(
'page_latest=rev_id' );
285 if (
$params[
'continue'] !==
null ) {
286 $cont = explode(
'|',
$params[
'continue'] );
288 $pageid = intval( $cont[0] );
289 $revid = intval( $cont[1] );
291 "rev_page > $pageid OR " .
292 "(rev_page = $pageid AND " .
304 $this->
addOption(
'LIMIT', $this->limit + 1 );
309 $res = $this->
select( __METHOD__, [], $hookData );
311 foreach (
$res as $row ) {
312 if ( ++$count > $this->limit ) {
315 if ( $enumRevMode ) {
317 $row->rev_timestamp .
'|' . intval( $row->rev_id ) );
318 } elseif ( $revCount > 0 ) {
322 '|' . intval( $row->rev_id ) );
327 if ( $resultPageSet !==
null ) {
328 $generated[] = $row->rev_id;
333 if ( $this->token !==
null ) {
334 $title = $revision->getTitle();
336 foreach ( $this->token
as $t ) {
338 if ( $val ===
false ) {
339 $this->
addWarning( [
'apiwarn-tokennotallowed', $t ] );
341 $rev[
$t .
'token'] = $val;
349 if ( $enumRevMode ) {
351 $row->rev_timestamp .
'|' . intval( $row->rev_id ) );
352 } elseif ( $revCount > 0 ) {
356 '|' . intval( $row->rev_id ) );
363 if ( $resultPageSet !==
null ) {
364 $resultPageSet->populateFromRevisionIDs( $generated );
369 if ( isset(
$params[
'token'] ) ) {
372 return parent::getCacheMode(
$params );
376 $ret = parent::getAllowedParams() + [
428 'action=query&prop=revisions&titles=API|Main%20Page&' .
429 'rvprop=timestamp|user|comment|content'
430 =>
'apihelp-query+revisions-example-content',
431 'action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
432 'rvprop=timestamp|user|comment'
433 =>
'apihelp-query+revisions-example-last5',
434 'action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
435 'rvprop=timestamp|user|comment&rvdir=newer'
436 =>
'apihelp-query+revisions-example-first5',
437 'action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
438 'rvprop=timestamp|user|comment&rvdir=newer&rvstart=2006-05-01T00:00:00Z'
439 =>
'apihelp-query+revisions-example-first5-after',
440 'action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
441 'rvprop=timestamp|user|comment&rvexcludeuser=127.0.0.1'
442 =>
'apihelp-query+revisions-example-first5-not-localhost',
443 'action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
444 'rvprop=timestamp|user|comment&rvuser=MediaWiki%20default'
445 =>
'apihelp-query+revisions-example-first5-user',
450 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Revisions';
parseParameters( $params)
Parse the parameters into the various instance fields.
processRow( $row, array &$data, array &$hookData)
Call the ApiQueryBaseProcessRow hook.
addFields( $value)
Add a set of fields to select to the internal array.
This is the main query class.
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
static getRollbackToken( $pageid, $title, $rev)
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
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 account $user
run(ApiPageSet $resultPageSet=null)
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
getUser()
Get the User object.
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
This class contains a list of pages that the client has requested.
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 selectTextFields()
Return the list of text fields that should be selected to read the revision text.
A base class for functions common to producing a list of revisions.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
null for the 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
getPageSet()
Get the PageSet object to work on.
namespace and then decline to actually register it file or subcat img or subcat $title
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
getDB()
Get the Query database connection (read-only)
getExamplesMessages()
Returns usage examples for this module.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
when a variable name is used in a it is silently declared as a new masking the global
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
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.
static selectPageFields()
Return the list of page fields that should be selected from page table.
extractRevisionInfo(Revision $revision, $row)
Extract information from the Revision.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
static newGood( $value=null)
Factory function for good results.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getCacheMode( $params)
Get the cache mode for the data generated by this module.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
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
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
getHelpUrls()
Return links to more detailed help pages about the module.
__construct(ApiQuery $query, $moduleName)
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
addWhere( $value)
Add a set of WHERE clauses to the internal array.
static selectUserFields()
Return the list of user fields that should be selected from user table.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
A query action to enumerate revisions of a given page, or show top revisions of multiple pages.