63 $contentHandlerFactory,
72 $this->revisionStore = $revisionStore;
73 $this->actorMigration = $actorMigration;
74 $this->namespaceInfo = $namespaceInfo;
75 $this->changeTagsStore = $changeTagsStore;
90 $tsField =
'rev_timestamp';
92 $pageField =
'rev_page';
97 $needPageTable =
false;
98 if ( $params[
'namespace'] !==
null ) {
99 $params[
'namespace'] = array_unique( $params[
'namespace'] );
100 sort( $params[
'namespace'] );
101 if ( $params[
'namespace'] != $this->namespaceInfo->getValidNamespaces() ) {
102 $needPageTable =
true;
104 $miser_ns = $params[
'namespace'];
106 $this->
addWhere( [
'page_namespace' => $params[
'namespace'] ] );
111 if ( $resultPageSet ===
null ) {
113 $queryBuilder = $this->revisionStore->newSelectQueryBuilder( $db )
120 $this->
addFields( [
'rev_timestamp',
'rev_id' ] );
122 if ( $params[
'generatetitles'] ) {
126 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
127 $this->
getQueryBuilder()->join(
'actor',
'actor_rev_user',
'actor_rev_user.actor_id = rev_actor' );
130 if ( $needPageTable ) {
131 $this->
getQueryBuilder()->join(
'page',
null, [
"$pageField = page_id" ] );
132 if ( (
bool)$miser_ns ) {
133 $this->
addFields( [
'page_namespace' ] );
141 $dir = $params[
'dir'];
144 if ( $this->fld_tags ) {
146 'ts_tags' => $this->changeTagsStore->makeTagSummarySubquery(
'revision' )
150 if ( $params[
'user'] !==
null ) {
151 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user', $params[
'user'] );
152 $this->
addWhere( $actorQuery[
'conds'] );
153 } elseif ( $params[
'excludeuser'] !==
null ) {
154 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user', $params[
'excludeuser'] );
155 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
158 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
160 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
161 $bitmask = RevisionRecord::DELETED_USER;
162 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
163 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
168 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
172 if ( $params[
'continue'] !==
null ) {
173 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
175 $this->
addWhere( $db->buildComparison( $op, [
176 $tsField => $db->timestamp( $cont[0] ),
177 $idField => $cont[1],
181 $this->
addOption(
'LIMIT', $this->limit + 1 );
183 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
187 $orderby[] =
"rev_timestamp $sort";
188 $orderby[] =
"rev_id $sort";
189 $this->
addOption(
'ORDER BY', $orderby );
192 $res = $this->
select( __METHOD__, [], $hookData );
194 if ( $resultPageSet ===
null ) {
202 foreach ( $res as $row ) {
203 if ( $count === 0 && $resultPageSet !==
null ) {
207 $this,
'continue',
"$row->rev_timestamp|$row->rev_id"
210 if ( ++$count > $this->limit ) {
217 if ( $miser_ns !==
null && !in_array( $row->page_namespace, $miser_ns ) ) {
221 if ( $resultPageSet !==
null ) {
222 if ( $params[
'generatetitles'] ) {
223 $generated[$row->rev_page] = $row->rev_page;
225 $generated[] = $row->rev_id;
228 $revision = $this->revisionStore->newRevisionFromRow( $row, 0, Title::newFromRow( $row ) );
231 if ( !isset( $pageMap[$row->rev_page] ) ) {
232 $index = $nextIndex++;
233 $pageMap[$row->rev_page] = $index;
234 $title = Title::newFromPageIdentity( $revision->getPage() );
236 'pageid' => $title->getArticleID(),
237 'revisions' => [ $rev ],
241 $fit = $this->
processRow( $row, $a[
'revisions'][0], $hookData ) &&
242 $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
244 $index = $pageMap[$row->rev_page];
245 $fit = $this->
processRow( $row, $rev, $hookData ) &&
246 $result->addValue( [
'query', $this->
getModuleName(), $index,
'revisions' ],
null, $rev );
255 if ( $resultPageSet !==
null ) {
256 if ( $params[
'generatetitles'] ) {
257 $resultPageSet->populateFromPageIDs( $generated );
259 $resultPageSet->populateFromRevisionIDs( $generated );
262 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
268 $ret = parent::getAllowedParams() + [
270 ParamValidator::PARAM_TYPE =>
'user',
271 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
272 UserDef::PARAM_RETURN_OBJECT =>
true,
275 ParamValidator::PARAM_ISMULTI =>
true,
276 ParamValidator::PARAM_TYPE =>
'namespace',
277 ParamValidator::PARAM_DEFAULT =>
null,
280 ParamValidator::PARAM_TYPE =>
'timestamp',
283 ParamValidator::PARAM_TYPE =>
'timestamp',
286 ParamValidator::PARAM_TYPE => [
290 ParamValidator::PARAM_DEFAULT =>
'older',
293 'newer' =>
'api-help-paramvalue-direction-newer',
294 'older' =>
'api-help-paramvalue-direction-older',
298 ParamValidator::PARAM_TYPE =>
'user',
299 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
300 UserDef::PARAM_RETURN_OBJECT =>
true,
305 'generatetitles' => [
306 ParamValidator::PARAM_DEFAULT =>
false,
312 'api-help-param-limited-in-miser-mode',
322 'action=query&list=allrevisions&arvuser=Example&arvlimit=50'
323 =>
'apihelp-query+allrevisions-example-user',
324 'action=query&list=allrevisions&arvdir=newer&arvlimit=50'
325 =>
'apihelp-query+allrevisions-example-ns-any',
331 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allrevisions';
336class_alias( ApiQueryAllRevisions::class,
'ApiQueryAllRevisions' );
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()