42 private $revisionStore;
45 private $actorMigration;
48 private $namespaceInfo;
79 $contentHandlerFactory,
85 $this->revisionStore = $revisionStore;
86 $this->actorMigration = $actorMigration;
87 $this->namespaceInfo = $namespaceInfo;
102 $tsField =
'rev_timestamp';
104 $pageField =
'rev_page';
109 $needPageTable =
false;
110 if ( $params[
'namespace'] !==
null ) {
111 $params[
'namespace'] = array_unique( $params[
'namespace'] );
112 sort( $params[
'namespace'] );
113 if ( $params[
'namespace'] != $this->namespaceInfo->getValidNamespaces() ) {
114 $needPageTable =
true;
115 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
116 $miser_ns = $params[
'namespace'];
118 $this->
addWhere( [
'page_namespace' => $params[
'namespace'] ] );
123 if ( $resultPageSet ===
null ) {
125 $revQuery = $this->revisionStore->getQueryInfo( [
'page' ] );
129 'tables' => [
'revision' ],
130 'fields' => [
'rev_timestamp',
'rev_id' ],
134 if ( $params[
'generatetitles'] ) {
138 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
139 $actorQuery = $this->actorMigration->getJoin(
'rev_user' );
140 $revQuery[
'tables'] += $actorQuery[
'tables'];
141 $revQuery[
'joins'] += $actorQuery[
'joins'];
144 if ( $needPageTable ) {
146 $revQuery[
'joins'][
'page'] = [
'JOIN', [
"$pageField = page_id" ] ];
147 if ( (
bool)$miser_ns ) {
148 $revQuery[
'fields'][] =
'page_namespace';
160 $dir = $params[
'dir'];
163 if ( $this->fld_tags ) {
167 if ( $params[
'user'] !==
null ) {
168 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user', $params[
'user'] );
169 $this->
addWhere( $actorQuery[
'conds'] );
170 } elseif ( $params[
'excludeuser'] !==
null ) {
171 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user', $params[
'excludeuser'] );
172 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
175 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
177 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
178 $bitmask = RevisionRecord::DELETED_USER;
179 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' )
181 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
186 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
190 if ( $params[
'continue'] !==
null ) {
191 $op = ( $dir ==
'newer' ?
'>' :
'<' );
192 $cont = explode(
'|', $params[
'continue'] );
194 $ts = $db->addQuotes( $db->timestamp( $cont[0] ) );
195 $rev_id = (int)$cont[1];
197 $this->
addWhere(
"$tsField $op $ts OR " .
198 "($tsField = $ts AND " .
199 "$idField $op= $rev_id)" );
202 $this->
addOption(
'LIMIT', $this->limit + 1 );
204 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
208 $orderby[] =
"rev_timestamp $sort";
209 $orderby[] =
"rev_id $sort";
210 $this->
addOption(
'ORDER BY', $orderby );
213 $res = $this->
select( __METHOD__, [], $hookData );
215 if ( $resultPageSet ===
null ) {
223 foreach (
$res as $row ) {
224 if ( $count === 0 && $resultPageSet !==
null ) {
228 $this,
'continue',
"$row->rev_timestamp|$row->rev_id"
231 if ( ++$count > $this->limit ) {
238 if ( $miser_ns !==
null && !in_array( $row->page_namespace, $miser_ns ) ) {
242 if ( $resultPageSet !==
null ) {
243 if ( $params[
'generatetitles'] ) {
244 $generated[$row->rev_page] = $row->rev_page;
246 $generated[] = $row->rev_id;
249 $revision = $this->revisionStore->newRevisionFromRow( $row, 0, Title::newFromRow( $row ) );
252 if ( !isset( $pageMap[$row->rev_page] ) ) {
253 $index = $nextIndex++;
254 $pageMap[$row->rev_page] = $index;
255 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
257 'pageid' =>
$title->getArticleID(),
258 'revisions' => [ $rev ],
260 ApiResult::setIndexedTagName( $a[
'revisions'],
'rev' );
262 $fit = $this->
processRow( $row, $a[
'revisions'][0], $hookData ) &&
263 $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
265 $index = $pageMap[$row->rev_page];
266 $fit = $this->
processRow( $row, $rev, $hookData ) &&
267 $result->addValue( [
'query', $this->
getModuleName(), $index,
'revisions' ],
null, $rev );
276 if ( $resultPageSet !==
null ) {
277 if ( $params[
'generatetitles'] ) {
278 $resultPageSet->populateFromPageIDs( $generated );
280 $resultPageSet->populateFromRevisionIDs( $generated );
283 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
288 $ret = parent::getAllowedParams() + [
290 ParamValidator::PARAM_TYPE =>
'user',
291 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
292 UserDef::PARAM_RETURN_OBJECT =>
true,
295 ParamValidator::PARAM_ISMULTI =>
true,
296 ParamValidator::PARAM_TYPE =>
'namespace',
297 ParamValidator::PARAM_DEFAULT =>
null,
300 ParamValidator::PARAM_TYPE =>
'timestamp',
303 ParamValidator::PARAM_TYPE =>
'timestamp',
306 ParamValidator::PARAM_TYPE => [
310 ParamValidator::PARAM_DEFAULT =>
'older',
313 'newer' =>
'api-help-paramvalue-direction-newer',
314 'older' =>
'api-help-paramvalue-direction-older',
318 ParamValidator::PARAM_TYPE =>
'user',
319 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
320 UserDef::PARAM_RETURN_OBJECT =>
true,
325 'generatetitles' => [
326 ParamValidator::PARAM_DEFAULT =>
false,
330 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
332 'api-help-param-limited-in-miser-mode',
341 'action=query&list=allrevisions&arvuser=Example&arvlimit=50'
342 =>
'apihelp-query+allrevisions-example-user',
343 'action=query&list=allrevisions&arvdir=newer&arvlimit=50'
344 =>
'apihelp-query+allrevisions-example-ns-any',
349 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allrevisions';
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 ...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
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.
__construct(ApiQuery $query, $moduleName, RevisionStore $revisionStore, IContentHandlerFactory $contentHandlerFactory, ParserFactory $parserFactory, SlotRoleRegistry $slotRoleRegistry, ActorMigration $actorMigration, NamespaceInfo $namespaceInfo, ContentRenderer $contentRenderer, ContentTransformer $contentTransformer)
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.
extractRevisionInfo(RevisionRecord $revision, $row)
Extract information from the RevisionRecord.
This is the main query class.
A service to render content.
A service to transform content.
A class containing constants representing the names of configuration variables.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...