77 $contentHandlerFactory,
86 $this->revisionStore = $revisionStore;
87 $this->actorMigration = $actorMigration;
88 $this->namespaceInfo = $namespaceInfo;
89 $this->changeTagsStore = $changeTagsStore;
104 $tsField =
'rev_timestamp';
106 $pageField =
'rev_page';
111 $needPageTable =
false;
112 if (
$params[
'namespace'] !==
null ) {
115 if (
$params[
'namespace'] != $this->namespaceInfo->getValidNamespaces() ) {
116 $needPageTable =
true;
118 $miser_ns =
$params[
'namespace'];
125 if ( $resultPageSet ===
null ) {
127 $queryBuilder = $this->revisionStore->newSelectQueryBuilder( $db )
134 $this->
addFields( [
'rev_timestamp',
'rev_id' ] );
136 if (
$params[
'generatetitles'] ) {
140 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
141 $this->
getQueryBuilder()->join(
'actor',
'actor_rev_user',
'actor_rev_user.actor_id = rev_actor' );
144 if ( $needPageTable ) {
145 $this->
getQueryBuilder()->join(
'page',
null, [
"$pageField = page_id" ] );
146 if ( (
bool)$miser_ns ) {
147 $this->
addFields( [
'page_namespace' ] );
158 if ( $this->fld_tags ) {
160 'ts_tags' => $this->changeTagsStore->makeTagSummarySubquery(
'revision' )
164 if (
$params[
'user'] !==
null ) {
165 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user',
$params[
'user'] );
166 $this->
addWhere( $actorQuery[
'conds'] );
167 } elseif (
$params[
'excludeuser'] !==
null ) {
168 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user',
$params[
'excludeuser'] );
169 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
172 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
174 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
175 $bitmask = RevisionRecord::DELETED_USER;
176 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
177 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
182 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
186 if (
$params[
'continue'] !==
null ) {
187 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
189 $this->
addWhere( $db->buildComparison( $op, [
190 $tsField => $db->timestamp( $cont[0] ),
191 $idField => $cont[1],
195 $this->
addOption(
'LIMIT', $this->limit + 1 );
197 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
201 $orderby[] =
"rev_timestamp $sort";
202 $orderby[] =
"rev_id $sort";
203 $this->
addOption(
'ORDER BY', $orderby );
206 $res = $this->
select( __METHOD__, [], $hookData );
208 if ( $resultPageSet ===
null ) {
216 foreach ( $res as $row ) {
217 if ( $count === 0 && $resultPageSet !==
null ) {
221 $this,
'continue',
"$row->rev_timestamp|$row->rev_id"
224 if ( ++$count > $this->limit ) {
231 if ( $miser_ns !==
null && !in_array( $row->page_namespace, $miser_ns ) ) {
235 if ( $resultPageSet !==
null ) {
236 if (
$params[
'generatetitles'] ) {
237 $generated[$row->rev_page] = $row->rev_page;
239 $generated[] = $row->rev_id;
242 $revision = $this->revisionStore->newRevisionFromRow( $row, 0, Title::newFromRow( $row ) );
245 if ( !isset( $pageMap[$row->rev_page] ) ) {
246 $index = $nextIndex++;
247 $pageMap[$row->rev_page] = $index;
248 $title = Title::newFromPageIdentity( $revision->getPage() );
250 'pageid' => $title->getArticleID(),
251 'revisions' => [ $rev ],
255 $fit = $this->
processRow( $row, $a[
'revisions'][0], $hookData ) &&
256 $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
258 $index = $pageMap[$row->rev_page];
259 $fit = $this->
processRow( $row, $rev, $hookData ) &&
260 $result->addValue( [
'query', $this->
getModuleName(), $index,
'revisions' ],
null, $rev );
269 if ( $resultPageSet !==
null ) {
270 if (
$params[
'generatetitles'] ) {
271 $resultPageSet->populateFromPageIDs( $generated );
273 $resultPageSet->populateFromRevisionIDs( $generated );
276 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
281 $ret = parent::getAllowedParams() + [
283 ParamValidator::PARAM_TYPE =>
'user',
284 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
285 UserDef::PARAM_RETURN_OBJECT =>
true,
288 ParamValidator::PARAM_ISMULTI =>
true,
289 ParamValidator::PARAM_TYPE =>
'namespace',
290 ParamValidator::PARAM_DEFAULT =>
null,
293 ParamValidator::PARAM_TYPE =>
'timestamp',
296 ParamValidator::PARAM_TYPE =>
'timestamp',
299 ParamValidator::PARAM_TYPE => [
303 ParamValidator::PARAM_DEFAULT =>
'older',
306 'newer' =>
'api-help-paramvalue-direction-newer',
307 'older' =>
'api-help-paramvalue-direction-older',
311 ParamValidator::PARAM_TYPE =>
'user',
312 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
313 UserDef::PARAM_RETURN_OBJECT =>
true,
318 'generatetitles' => [
319 ParamValidator::PARAM_DEFAULT =>
false,
325 'api-help-param-limited-in-miser-mode',
334 'action=query&list=allrevisions&arvuser=Example&arvlimit=50'
335 =>
'apihelp-query+allrevisions-example-user',
336 'action=query&list=allrevisions&arvdir=newer&arvlimit=50'
337 =>
'apihelp-query+allrevisions-example-ns-any',
342 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allrevisions';
347class_alias( ApiQueryAllRevisions::class,
'ApiQueryAllRevisions' );
array $params
The job parameters.
This class contains a list of pages that the client has requested.
A service to render content.
A service to transform content.
A class containing constants representing the names of configuration variables.
const MiserMode
Name constant for the MiserMode setting, for use with Config::get()