36 parent::__construct( $query, $moduleName,
'arv' );
46 $services = MediaWikiServices::getInstance();
47 $revisionStore = $services->getRevisionStore();
53 $tsField =
'rev_timestamp';
55 $pageField =
'rev_page';
56 if ( $params[
'user'] !==
null ) {
59 $tsField =
'revactor_timestamp';
60 $idField =
'revactor_rev';
61 $pageField =
'revactor_page';
67 $needPageTable =
false;
68 if ( $params[
'namespace'] !==
null ) {
69 $params[
'namespace'] = array_unique( $params[
'namespace'] );
70 sort( $params[
'namespace'] );
71 if ( $params[
'namespace'] != $services->getNamespaceInfo()->getValidNamespaces() ) {
72 $needPageTable =
true;
73 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
74 $miser_ns = $params[
'namespace'];
76 $this->
addWhere( [
'page_namespace' => $params[
'namespace'] ] );
81 if ( $resultPageSet ===
null ) {
83 $revQuery = $revisionStore->getQueryInfo( [
'page' ] );
87 'tables' => [
'revision' ],
88 'fields' => [
'rev_timestamp',
'rev_id' ],
92 if ( $params[
'generatetitles'] ) {
96 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
97 $actorQuery = ActorMigration::newMigration()->getJoin(
'rev_user' );
98 $revQuery[
'tables'] += $actorQuery[
'tables'];
99 $revQuery[
'joins'] += $actorQuery[
'joins'];
102 if ( $needPageTable ) {
104 $revQuery[
'joins'][
'page'] = [
'JOIN', [
"$pageField = page_id" ] ];
105 if ( (
bool)$miser_ns ) {
106 $revQuery[
'fields'][] =
'page_namespace';
113 if ( $idField !==
'rev_id' && isset(
$revQuery[
'tables'][
'temp_rev_user'] ) ) {
114 $aliasFields = [
'rev_id' => $idField,
'rev_timestamp' => $tsField,
'rev_page' => $pageField ];
117 array_diff(
$revQuery[
'fields'], array_keys( $aliasFields ) )
119 unset(
$revQuery[
'tables'][
'temp_rev_user'] );
121 [
'temp_rev_user' =>
'revision_actor_temp' ],
125 unset(
$revQuery[
'joins'][
'temp_rev_user'] );
135 $dir = $params[
'dir'];
138 if ( $this->fld_tags ) {
142 if ( $params[
'user'] !==
null ) {
143 $actorQuery = ActorMigration::newMigration()
144 ->getWhere( $db,
'rev_user', $params[
'user'] );
145 $this->
addWhere( $actorQuery[
'conds'] );
146 } elseif ( $params[
'excludeuser'] !==
null ) {
147 $actorQuery = ActorMigration::newMigration()
148 ->getWhere( $db,
'rev_user', $params[
'excludeuser'] );
149 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
152 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
155 $bitmask = RevisionRecord::DELETED_USER;
157 ->userHasAnyRight( $this->
getUser(),
'suppressrevision',
'viewsuppressed' )
159 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
164 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
168 if ( $params[
'continue'] !==
null ) {
169 $op = ( $dir ==
'newer' ?
'>' :
'<' );
170 $cont = explode(
'|', $params[
'continue'] );
172 $ts = $db->addQuotes( $db->timestamp( $cont[0] ) );
173 $rev_id = (int)$cont[1];
175 $this->
addWhere(
"$tsField $op $ts OR " .
176 "($tsField = $ts AND " .
177 "$idField $op= $rev_id)" );
180 $this->
addOption(
'LIMIT', $this->limit + 1 );
182 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
186 $orderby[] =
"rev_timestamp $sort";
187 $orderby[] =
"rev_id $sort";
188 $this->
addOption(
'ORDER BY', $orderby );
191 $res = $this->
select( __METHOD__, [], $hookData );
193 if ( $resultPageSet ===
null ) {
201 foreach (
$res as $row ) {
202 if ( $count === 0 && $resultPageSet !==
null ) {
206 $this,
'continue',
"$row->rev_timestamp|$row->rev_id"
209 if ( ++$count > $this->limit ) {
216 if ( $miser_ns !==
null && !in_array( $row->page_namespace, $miser_ns ) ) {
220 if ( $resultPageSet !==
null ) {
221 if ( $params[
'generatetitles'] ) {
222 $generated[$row->rev_page] = $row->rev_page;
224 $generated[] = $row->rev_id;
227 $revision = $revisionStore->newRevisionFromRow( $row, 0, Title::newFromRow( $row ) );
230 if ( !isset( $pageMap[$row->rev_page] ) ) {
231 $index = $nextIndex++;
232 $pageMap[$row->rev_page] = $index;
233 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
235 'pageid' =>
$title->getArticleID(),
236 'revisions' => [ $rev ],
238 ApiResult::setIndexedTagName( $a[
'revisions'],
'rev' );
240 $fit = $this->
processRow( $row, $a[
'revisions'][0], $hookData ) &&
241 $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
243 $index = $pageMap[$row->rev_page];
244 $fit = $this->
processRow( $row, $rev, $hookData ) &&
245 $result->addValue( [
'query', $this->
getModuleName(), $index,
'revisions' ],
null, $rev );
254 if ( $resultPageSet !==
null ) {
255 if ( $params[
'generatetitles'] ) {
256 $resultPageSet->populateFromPageIDs( $generated );
258 $resultPageSet->populateFromRevisionIDs( $generated );
261 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
266 $ret = parent::getAllowedParams() + [
269 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
270 UserDef::PARAM_RETURN_OBJECT =>
true,
293 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
294 UserDef::PARAM_RETURN_OBJECT =>
true,
299 'generatetitles' => [
304 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
306 'api-help-param-limited-in-miser-mode',
315 'action=query&list=allrevisions&arvuser=Example&arvlimit=50'
316 =>
'apihelp-query+allrevisions-example-user',
317 'action=query&list=allrevisions&arvdir=newer&arvlimit=50'
318 =>
'apihelp-query+allrevisions-example-ns-any',
323 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allrevisions';
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
requireMaxOneParameter( $params,... $required)
Die if more than one of a certain set of parameters is set and not false.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
getModuleName()
Get the name of the module being executed by this instance.
getContinuationManager()
Get the continuation manager.
This class contains a list of pages that the client has requested.
Query module to enumerate all revisions.
getHelpUrls()
Return links to more detailed help pages about the module.
getAllowedParams()
Stable to override.
__construct(ApiQuery $query, $moduleName)
getExamplesMessages()
Returns usage examples for this module.
run(ApiPageSet $resultPageSet=null)
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
processRow( $row, array &$data, array &$hookData)
Call the ApiQueryBaseProcessRow hook.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
getDB()
Get the Query database connection (read-only) Stable to override.
executeGenderCacheFromResultWrapper(IResultWrapper $res, $fname=__METHOD__, $fieldPrefix='page')
Preprocess the result set to fill the GenderCache with the necessary information before using self::a...
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
A base class for functions common to producing a list of revisions.
parseParameters( $params)
Parse the parameters into the various instance fields.
extractRevisionInfo(RevisionRecord $revision, $row)
Extract information from the RevisionRecord.
This is the main query class.