86 $contentHandlerFactory,
95 $this->revisionStore = $revisionStore;
96 $this->actorMigration = $actorMigration;
97 $this->namespaceInfo = $namespaceInfo;
105 $db = $this->
getDB();
112 $tsField =
'rev_timestamp';
114 $pageField =
'rev_page';
119 $needPageTable =
false;
120 if ( $params[
'namespace'] !==
null ) {
121 $params[
'namespace'] = array_unique( $params[
'namespace'] );
122 sort( $params[
'namespace'] );
123 if ( $params[
'namespace'] != $this->namespaceInfo->getValidNamespaces() ) {
124 $needPageTable =
true;
125 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
126 $miser_ns = $params[
'namespace'];
128 $this->
addWhere( [
'page_namespace' => $params[
'namespace'] ] );
133 if ( $resultPageSet ===
null ) {
135 $queryBuilder = $this->revisionStore->newSelectQueryBuilder( $db )
142 $this->
addFields( [
'rev_timestamp',
'rev_id' ] );
144 if ( $params[
'generatetitles'] ) {
148 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
149 $this->
getQueryBuilder()->join(
'actor',
'actor_rev_user',
'actor_rev_user.actor_id = rev_actor' );
152 if ( $needPageTable ) {
153 $this->
getQueryBuilder()->join(
'page',
null, [
"$pageField = page_id" ] );
154 if ( (
bool)$miser_ns ) {
155 $this->
addFields( [
'page_namespace' ] );
163 $dir = $params[
'dir'];
166 if ( $this->fld_tags ) {
170 if ( $params[
'user'] !==
null ) {
171 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user', $params[
'user'] );
172 $this->
addWhere( $actorQuery[
'conds'] );
173 } elseif ( $params[
'excludeuser'] !==
null ) {
174 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user', $params[
'excludeuser'] );
175 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
178 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
180 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
181 $bitmask = RevisionRecord::DELETED_USER;
182 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
183 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
188 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
192 if ( $params[
'continue'] !==
null ) {
193 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
195 $this->
addWhere( $db->buildComparison( $op, [
196 $tsField => $db->timestamp( $cont[0] ),
197 $idField => $cont[1],
201 $this->
addOption(
'LIMIT', $this->limit + 1 );
203 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
207 $orderby[] =
"rev_timestamp $sort";
208 $orderby[] =
"rev_id $sort";
209 $this->
addOption(
'ORDER BY', $orderby );
212 $res = $this->
select( __METHOD__, [], $hookData );
214 if ( $resultPageSet ===
null ) {
222 foreach ( $res as $row ) {
223 if ( $count === 0 && $resultPageSet !==
null ) {
227 $this,
'continue',
"$row->rev_timestamp|$row->rev_id"
230 if ( ++$count > $this->limit ) {
237 if ( $miser_ns !==
null && !in_array( $row->page_namespace, $miser_ns ) ) {
241 if ( $resultPageSet !==
null ) {
242 if ( $params[
'generatetitles'] ) {
243 $generated[$row->rev_page] = $row->rev_page;
245 $generated[] = $row->rev_id;
248 $revision = $this->revisionStore->newRevisionFromRow( $row, 0, Title::newFromRow( $row ) );
251 if ( !isset( $pageMap[$row->rev_page] ) ) {
252 $index = $nextIndex++;
253 $pageMap[$row->rev_page] = $index;
254 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
256 'pageid' => $title->getArticleID(),
257 'revisions' => [ $rev ],
261 $fit = $this->
processRow( $row, $a[
'revisions'][0], $hookData ) &&
262 $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
264 $index = $pageMap[$row->rev_page];
265 $fit = $this->
processRow( $row, $rev, $hookData ) &&
266 $result->addValue( [
'query', $this->
getModuleName(), $index,
'revisions' ],
null, $rev );
275 if ( $resultPageSet !==
null ) {
276 if ( $params[
'generatetitles'] ) {
277 $resultPageSet->populateFromPageIDs( $generated );
279 $resultPageSet->populateFromRevisionIDs( $generated );
282 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
287 $ret = parent::getAllowedParams() + [
289 ParamValidator::PARAM_TYPE =>
'user',
290 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
291 UserDef::PARAM_RETURN_OBJECT =>
true,
294 ParamValidator::PARAM_ISMULTI =>
true,
295 ParamValidator::PARAM_TYPE =>
'namespace',
296 ParamValidator::PARAM_DEFAULT =>
null,
299 ParamValidator::PARAM_TYPE =>
'timestamp',
302 ParamValidator::PARAM_TYPE =>
'timestamp',
305 ParamValidator::PARAM_TYPE => [
309 ParamValidator::PARAM_DEFAULT =>
'older',
312 'newer' =>
'api-help-paramvalue-direction-newer',
313 'older' =>
'api-help-paramvalue-direction-older',
317 ParamValidator::PARAM_TYPE =>
'user',
318 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
319 UserDef::PARAM_RETURN_OBJECT =>
true,
324 'generatetitles' => [
325 ParamValidator::PARAM_DEFAULT =>
false,
329 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
331 'api-help-param-limited-in-miser-mode',
340 'action=query&list=allrevisions&arvuser=Example&arvlimit=50'
341 =>
'apihelp-query+allrevisions-example-user',
342 'action=query&list=allrevisions&arvdir=newer&arvlimit=50'
343 =>
'apihelp-query+allrevisions-example-ns-any',
348 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)
Dies if more than one parameter from a certain set of parameters are 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.
getHelpUrls()
Return links to more detailed help pages about the module.
getAllowedParams()
@stable to override
__construct(ApiQuery $query, $moduleName, RevisionStore $revisionStore, IContentHandlerFactory $contentHandlerFactory, ParserFactory $parserFactory, SlotRoleRegistry $slotRoleRegistry, ActorMigration $actorMigration, NamespaceInfo $namespaceInfo, ContentRenderer $contentRenderer, ContentTransformer $contentTransformer, CommentFormatter $commentFormatter, TempUserCreator $tempUserCreator, UserFactory $userFactory)
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.
getQueryBuilder()
Get the SelectQueryBuilder.
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.
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.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
A service to render content.
A service to transform content.
A class containing constants representing the names of configuration variables.