Go to the documentation of this file.
35 parent::__construct( $query, $moduleName,
'arv' );
45 $services = MediaWikiServices::getInstance();
46 $revisionStore = $services->getRevisionStore();
52 $tsField =
'rev_timestamp';
54 $pageField =
'rev_page';
55 if ( $params[
'user'] !==
null ) {
58 $tsField =
'revactor_timestamp';
59 $idField =
'revactor_rev';
60 $pageField =
'revactor_page';
66 $needPageTable =
false;
67 if ( $params[
'namespace'] !==
null ) {
68 $params[
'namespace'] = array_unique( $params[
'namespace'] );
69 sort( $params[
'namespace'] );
70 if ( $params[
'namespace'] != $services->getNamespaceInfo()->getValidNamespaces() ) {
71 $needPageTable =
true;
72 if ( $this->
getConfig()->get(
'MiserMode' ) ) {
73 $miser_ns = $params[
'namespace'];
75 $this->
addWhere( [
'page_namespace' => $params[
'namespace'] ] );
80 if ( $resultPageSet ===
null ) {
82 $revQuery = $revisionStore->getQueryInfo( [
'page' ] );
86 'tables' => [
'revision' ],
87 'fields' => [
'rev_timestamp',
'rev_id' ],
91 if ( $params[
'generatetitles'] ) {
95 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
97 $revQuery[
'tables'] += $actorQuery[
'tables'];
98 $revQuery[
'joins'] += $actorQuery[
'joins'];
101 if ( $needPageTable ) {
103 $revQuery[
'joins'][
'page'] = [
'JOIN', [
"$pageField = page_id" ] ];
104 if ( (
bool)$miser_ns ) {
105 $revQuery[
'fields'][] =
'page_namespace';
112 if ( $idField !==
'rev_id' && isset(
$revQuery[
'tables'][
'temp_rev_user'] ) ) {
113 $aliasFields = [
'rev_id' => $idField,
'rev_timestamp' => $tsField,
'rev_page' => $pageField ];
116 array_diff(
$revQuery[
'fields'], array_keys( $aliasFields ) )
118 unset(
$revQuery[
'tables'][
'temp_rev_user'] );
120 [
'temp_rev_user' =>
'revision_actor_temp' ],
124 unset(
$revQuery[
'joins'][
'temp_rev_user'] );
134 $dir = $params[
'dir'];
137 if ( $this->fld_tags ) {
141 if ( $params[
'user'] !==
null ) {
144 $this->
addWhere( $actorQuery[
'conds'] );
145 } elseif ( $params[
'excludeuser'] !==
null ) {
147 ->getWhere( $db,
'rev_user',
User::newFromName( $params[
'excludeuser'],
false ) );
148 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
151 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
154 $bitmask = RevisionRecord::DELETED_USER;
156 ->userHasAnyRight( $this->
getUser(),
'suppressrevision',
'viewsuppressed' )
158 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
163 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
167 if ( $params[
'continue'] !==
null ) {
168 $op = ( $dir ==
'newer' ?
'>' :
'<' );
169 $cont = explode(
'|', $params[
'continue'] );
171 $ts = $db->addQuotes( $db->timestamp( $cont[0] ) );
172 $rev_id = (int)$cont[1];
174 $this->
addWhere(
"$tsField $op $ts OR " .
175 "($tsField = $ts AND " .
176 "$idField $op= $rev_id)" );
179 $this->
addOption(
'LIMIT', $this->limit + 1 );
181 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
185 $orderby[] =
"rev_timestamp $sort";
186 $orderby[] =
"rev_id $sort";
187 $this->
addOption(
'ORDER BY', $orderby );
190 $res = $this->
select( __METHOD__, [], $hookData );
195 foreach (
$res as $row ) {
196 if ( $count === 0 && $resultPageSet !==
null ) {
200 $this,
'continue',
"$row->rev_timestamp|$row->rev_id"
203 if ( ++$count > $this->limit ) {
210 if ( $miser_ns !==
null && !in_array( $row->page_namespace, $miser_ns ) ) {
214 if ( $resultPageSet !==
null ) {
215 if ( $params[
'generatetitles'] ) {
216 $generated[$row->rev_page] = $row->rev_page;
218 $generated[] = $row->rev_id;
221 $revision = $revisionStore->newRevisionFromRow( $row );
224 if ( !isset( $pageMap[$row->rev_page] ) ) {
225 $index = $nextIndex++;
226 $pageMap[$row->rev_page] = $index;
229 'pageid' =>
$title->getArticleID(),
230 'revisions' => [ $rev ],
234 $fit = $this->
processRow( $row, $a[
'revisions'][0], $hookData ) &&
235 $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
237 $index = $pageMap[$row->rev_page];
238 $fit = $this->
processRow( $row, $rev, $hookData ) &&
239 $result->addValue( [
'query', $this->
getModuleName(), $index,
'revisions' ],
null, $rev );
248 if ( $resultPageSet !==
null ) {
249 if ( $params[
'generatetitles'] ) {
250 $resultPageSet->populateFromPageIDs( $generated );
252 $resultPageSet->populateFromRevisionIDs( $generated );
255 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
260 $ret = parent::getAllowedParams() + [
289 'generatetitles' => [
294 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
296 'api-help-param-limited-in-miser-mode',
305 'action=query&list=allrevisions&arvuser=Example&arvlimit=50'
306 =>
'apihelp-query+allrevisions-example-user',
307 'action=query&list=allrevisions&arvdir=newer&arvlimit=50'
308 =>
'apihelp-query+allrevisions-example-ns-main',
313 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allrevisions';
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.
run(ApiPageSet $resultPageSet=null)
This is the main query class.
getExamplesMessages()
Returns usage examples for this module.
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.
getResult()
Get the result object.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
getHelpUrls()
Return links to more detailed help pages about the module.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
static newMigration()
Static constructor.
This class contains a list of pages that the client has requested.
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.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getDB()
Get the Query database connection (read-only)
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.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Query module to enumerate all revisions.
getContinuationManager()
Get the continuation manager.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
extractRevisionInfo(RevisionRecord $revision, $row)
Extract information from the RevisionRecord.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
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.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
__construct(ApiQuery $query, $moduleName)
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.