45 private $revisionStore;
48 private $actorMigration;
51 private $namespaceInfo;
84 $contentHandlerFactory,
91 $this->revisionStore = $revisionStore;
92 $this->actorMigration = $actorMigration;
93 $this->namespaceInfo = $namespaceInfo;
101 $db = $this->
getDB();
108 $tsField =
'rev_timestamp';
110 $pageField =
'rev_page';
115 $needPageTable =
false;
116 if ( $params[
'namespace'] !==
null ) {
117 $params[
'namespace'] = array_unique( $params[
'namespace'] );
118 sort( $params[
'namespace'] );
119 if ( $params[
'namespace'] != $this->namespaceInfo->getValidNamespaces() ) {
120 $needPageTable =
true;
121 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
122 $miser_ns = $params[
'namespace'];
124 $this->
addWhere( [
'page_namespace' => $params[
'namespace'] ] );
129 if ( $resultPageSet ===
null ) {
131 $revQuery = $this->revisionStore->getQueryInfo( [
'page' ] );
135 'tables' => [
'revision' ],
136 'fields' => [
'rev_timestamp',
'rev_id' ],
140 if ( $params[
'generatetitles'] ) {
144 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
145 $actorQuery = $this->actorMigration->getJoin(
'rev_user' );
146 $revQuery[
'tables'] += $actorQuery[
'tables'];
147 $revQuery[
'joins'] += $actorQuery[
'joins'];
150 if ( $needPageTable ) {
152 $revQuery[
'joins'][
'page'] = [
'JOIN', [
"$pageField = page_id" ] ];
153 if ( (
bool)$miser_ns ) {
154 $revQuery[
'fields'][] =
'page_namespace';
166 $dir = $params[
'dir'];
169 if ( $this->fld_tags ) {
173 if ( $params[
'user'] !==
null ) {
174 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user', $params[
'user'] );
175 $this->
addWhere( $actorQuery[
'conds'] );
176 } elseif ( $params[
'excludeuser'] !==
null ) {
177 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user', $params[
'excludeuser'] );
178 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
181 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
183 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
184 $bitmask = RevisionRecord::DELETED_USER;
185 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' )
187 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
192 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
196 if ( $params[
'continue'] !==
null ) {
197 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
199 $this->
addWhere( $db->buildComparison( $op, [
200 $tsField => $db->timestamp( $cont[0] ),
201 $idField => $cont[1],
205 $this->
addOption(
'LIMIT', $this->limit + 1 );
207 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
211 $orderby[] =
"rev_timestamp $sort";
212 $orderby[] =
"rev_id $sort";
213 $this->
addOption(
'ORDER BY', $orderby );
216 $res = $this->
select( __METHOD__, [], $hookData );
218 if ( $resultPageSet ===
null ) {
226 foreach (
$res as $row ) {
227 if ( $count === 0 && $resultPageSet !==
null ) {
231 $this,
'continue',
"$row->rev_timestamp|$row->rev_id"
234 if ( ++$count > $this->limit ) {
241 if ( $miser_ns !==
null && !in_array( $row->page_namespace, $miser_ns ) ) {
245 if ( $resultPageSet !==
null ) {
246 if ( $params[
'generatetitles'] ) {
247 $generated[$row->rev_page] = $row->rev_page;
249 $generated[] = $row->rev_id;
252 $revision = $this->revisionStore->newRevisionFromRow( $row, 0, Title::newFromRow( $row ) );
255 if ( !isset( $pageMap[$row->rev_page] ) ) {
256 $index = $nextIndex++;
257 $pageMap[$row->rev_page] = $index;
258 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
260 'pageid' =>
$title->getArticleID(),
261 'revisions' => [ $rev ],
263 ApiResult::setIndexedTagName( $a[
'revisions'],
'rev' );
265 $fit = $this->
processRow( $row, $a[
'revisions'][0], $hookData ) &&
266 $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
268 $index = $pageMap[$row->rev_page];
269 $fit = $this->
processRow( $row, $rev, $hookData ) &&
270 $result->addValue( [
'query', $this->
getModuleName(), $index,
'revisions' ],
null, $rev );
279 if ( $resultPageSet !==
null ) {
280 if ( $params[
'generatetitles'] ) {
281 $resultPageSet->populateFromPageIDs( $generated );
283 $resultPageSet->populateFromRevisionIDs( $generated );
286 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
291 $ret = parent::getAllowedParams() + [
293 ParamValidator::PARAM_TYPE =>
'user',
294 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
295 UserDef::PARAM_RETURN_OBJECT =>
true,
298 ParamValidator::PARAM_ISMULTI =>
true,
299 ParamValidator::PARAM_TYPE =>
'namespace',
300 ParamValidator::PARAM_DEFAULT =>
null,
303 ParamValidator::PARAM_TYPE =>
'timestamp',
306 ParamValidator::PARAM_TYPE =>
'timestamp',
309 ParamValidator::PARAM_TYPE => [
313 ParamValidator::PARAM_DEFAULT =>
'older',
316 'newer' =>
'api-help-paramvalue-direction-newer',
317 'older' =>
'api-help-paramvalue-direction-older',
321 ParamValidator::PARAM_TYPE =>
'user',
322 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
323 UserDef::PARAM_RETURN_OBJECT =>
true,
328 'generatetitles' => [
329 ParamValidator::PARAM_DEFAULT =>
false,
333 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
335 'api-help-param-limited-in-miser-mode',
344 'action=query&list=allrevisions&arvuser=Example&arvlimit=50'
345 =>
'apihelp-query+allrevisions-example-user',
346 'action=query&list=allrevisions&arvdir=newer&arvlimit=50'
347 =>
'apihelp-query+allrevisions-example-ns-any',
352 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allrevisions';
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
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, CommentFormatter $commentFormatter)
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...