98 $tsField =
'rev_timestamp';
100 $pageField =
'rev_page';
101 if ( $params[
'user'] !==
null &&
106 $tsField =
'revactor_timestamp';
107 $idField =
'revactor_rev';
108 $pageField =
'revactor_page';
114 $needPageTable =
false;
115 if ( $params[
'namespace'] !==
null ) {
116 $params[
'namespace'] = array_unique( $params[
'namespace'] );
117 sort( $params[
'namespace'] );
118 if ( $params[
'namespace'] != $this->namespaceInfo->getValidNamespaces() ) {
119 $needPageTable =
true;
120 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
121 $miser_ns = $params[
'namespace'];
123 $this->
addWhere( [
'page_namespace' => $params[
'namespace'] ] );
128 if ( $resultPageSet ===
null ) {
130 $revQuery = $this->revisionStore->getQueryInfo( [
'page' ] );
134 'tables' => [
'revision' ],
135 'fields' => [
'rev_timestamp',
'rev_id' ],
139 if ( $params[
'generatetitles'] ) {
143 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
144 $actorQuery = $this->actorMigration->getJoin(
'rev_user' );
145 $revQuery[
'tables'] += $actorQuery[
'tables'];
146 $revQuery[
'joins'] += $actorQuery[
'joins'];
149 if ( $needPageTable ) {
151 $revQuery[
'joins'][
'page'] = [
'JOIN', [
"$pageField = page_id" ] ];
152 if ( (
bool)$miser_ns ) {
153 $revQuery[
'fields'][] =
'page_namespace';
160 if ( $idField !==
'rev_id' && isset(
$revQuery[
'tables'][
'temp_rev_user'] ) ) {
161 $aliasFields = [
'rev_id' => $idField,
'rev_timestamp' => $tsField,
'rev_page' => $pageField ];
164 array_diff(
$revQuery[
'fields'], array_keys( $aliasFields ) )
166 unset(
$revQuery[
'tables'][
'temp_rev_user'] );
168 [
'temp_rev_user' =>
'revision_actor_temp' ],
172 unset(
$revQuery[
'joins'][
'temp_rev_user'] );
182 $dir = $params[
'dir'];
185 if ( $this->fld_tags ) {
189 if ( $params[
'user'] !==
null ) {
190 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user', $params[
'user'] );
191 $this->
addWhere( $actorQuery[
'conds'] );
192 } elseif ( $params[
'excludeuser'] !==
null ) {
193 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user', $params[
'excludeuser'] );
194 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
197 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
199 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
200 $bitmask = RevisionRecord::DELETED_USER;
201 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' )
203 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
208 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
212 if ( $params[
'continue'] !==
null ) {
213 $op = ( $dir ==
'newer' ?
'>' :
'<' );
214 $cont = explode(
'|', $params[
'continue'] );
216 $ts = $db->addQuotes( $db->timestamp( $cont[0] ) );
217 $rev_id = (int)$cont[1];
219 $this->
addWhere(
"$tsField $op $ts OR " .
220 "($tsField = $ts AND " .
221 "$idField $op= $rev_id)" );
224 $this->
addOption(
'LIMIT', $this->limit + 1 );
226 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
230 $orderby[] =
"rev_timestamp $sort";
231 $orderby[] =
"rev_id $sort";
232 $this->
addOption(
'ORDER BY', $orderby );
235 $res = $this->
select( __METHOD__, [], $hookData );
237 if ( $resultPageSet ===
null ) {
245 foreach (
$res as $row ) {
246 if ( $count === 0 && $resultPageSet !==
null ) {
250 $this,
'continue',
"$row->rev_timestamp|$row->rev_id"
253 if ( ++$count > $this->limit ) {
260 if ( $miser_ns !==
null && !in_array( $row->page_namespace, $miser_ns ) ) {
264 if ( $resultPageSet !==
null ) {
265 if ( $params[
'generatetitles'] ) {
266 $generated[$row->rev_page] = $row->rev_page;
268 $generated[] = $row->rev_id;
271 $revision = $this->revisionStore->newRevisionFromRow( $row, 0, Title::newFromRow( $row ) );
274 if ( !isset( $pageMap[$row->rev_page] ) ) {
275 $index = $nextIndex++;
276 $pageMap[$row->rev_page] = $index;
277 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
279 'pageid' =>
$title->getArticleID(),
280 'revisions' => [ $rev ],
282 ApiResult::setIndexedTagName( $a[
'revisions'],
'rev' );
284 $fit = $this->
processRow( $row, $a[
'revisions'][0], $hookData ) &&
285 $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
287 $index = $pageMap[$row->rev_page];
288 $fit = $this->
processRow( $row, $rev, $hookData ) &&
289 $result->addValue( [
'query', $this->
getModuleName(), $index,
'revisions' ],
null, $rev );
298 if ( $resultPageSet !==
null ) {
299 if ( $params[
'generatetitles'] ) {
300 $resultPageSet->populateFromPageIDs( $generated );
302 $resultPageSet->populateFromRevisionIDs( $generated );
305 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
310 $ret = parent::getAllowedParams() + [
313 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
314 UserDef::PARAM_RETURN_OBJECT =>
true,
337 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
338 UserDef::PARAM_RETURN_OBJECT =>
true,
343 'generatetitles' => [
348 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
350 'api-help-param-limited-in-miser-mode',
359 'action=query&list=allrevisions&arvuser=Example&arvlimit=50'
360 =>
'apihelp-query+allrevisions-example-user',
361 'action=query&list=allrevisions&arvdir=newer&arvlimit=50'
362 =>
'apihelp-query+allrevisions-example-ns-any',
367 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allrevisions';
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage, for migration from the temporary table revision_actor_temp to the...
const SCHEMA_COMPAT_READ_TEMP
This is not intended to be a long-term part of MediaWiki; it will be deprecated and removed once acto...
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 ...
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.
This class contains a list of pages that the client has requested.
Query module to enumerate all revisions.
ActorMigration $actorMigration
__construct(ApiQuery $query, $moduleName, RevisionStore $revisionStore, IContentHandlerFactory $contentHandlerFactory, ParserFactory $parserFactory, SlotRoleRegistry $slotRoleRegistry, ActorMigration $actorMigration, NamespaceInfo $namespaceInfo, ContentTransformer $contentTransformer)
NamespaceInfo $namespaceInfo
RevisionStore $revisionStore
getHelpUrls()
Return links to more detailed help pages about the module.
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)
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.
IContentHandlerFactory $contentHandlerFactory
ContentTransformer $contentTransformer
SlotRoleRegistry $slotRoleRegistry
ParserFactory $parserFactory
extractRevisionInfo(RevisionRecord $revision, $row)
Extract information from the RevisionRecord.
This is the main query class.
A service to transform content.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...