75 $contentHandlerFactory,
84 $this->revisionStore = $revisionStore;
85 $this->actorMigration = $actorMigration;
86 $this->namespaceInfo = $namespaceInfo;
101 $tsField =
'rev_timestamp';
103 $pageField =
'rev_page';
108 $needPageTable =
false;
109 if (
$params[
'namespace'] !==
null ) {
112 if (
$params[
'namespace'] != $this->namespaceInfo->getValidNamespaces() ) {
113 $needPageTable =
true;
115 $miser_ns =
$params[
'namespace'];
122 if ( $resultPageSet ===
null ) {
124 $queryBuilder = $this->revisionStore->newSelectQueryBuilder( $db )
131 $this->
addFields( [
'rev_timestamp',
'rev_id' ] );
133 if (
$params[
'generatetitles'] ) {
137 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
138 $this->
getQueryBuilder()->join(
'actor',
'actor_rev_user',
'actor_rev_user.actor_id = rev_actor' );
141 if ( $needPageTable ) {
142 $this->
getQueryBuilder()->join(
'page',
null, [
"$pageField = page_id" ] );
143 if ( (
bool)$miser_ns ) {
144 $this->
addFields( [
'page_namespace' ] );
155 if ( $this->fld_tags ) {
158 ->makeTagSummarySubquery(
'revision' )
162 if (
$params[
'user'] !==
null ) {
163 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user',
$params[
'user'] );
164 $this->
addWhere( $actorQuery[
'conds'] );
165 } elseif (
$params[
'excludeuser'] !==
null ) {
166 $actorQuery = $this->actorMigration->getWhere( $db,
'rev_user',
$params[
'excludeuser'] );
167 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
170 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
172 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
173 $bitmask = RevisionRecord::DELETED_USER;
174 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
175 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
180 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
184 if (
$params[
'continue'] !==
null ) {
185 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
187 $this->
addWhere( $db->buildComparison( $op, [
188 $tsField => $db->timestamp( $cont[0] ),
189 $idField => $cont[1],
193 $this->
addOption(
'LIMIT', $this->limit + 1 );
195 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
199 $orderby[] =
"rev_timestamp $sort";
200 $orderby[] =
"rev_id $sort";
201 $this->
addOption(
'ORDER BY', $orderby );
204 $res = $this->
select( __METHOD__, [], $hookData );
206 if ( $resultPageSet ===
null ) {
214 foreach ( $res as $row ) {
215 if ( $count === 0 && $resultPageSet !==
null ) {
219 $this,
'continue',
"$row->rev_timestamp|$row->rev_id"
222 if ( ++$count > $this->limit ) {
229 if ( $miser_ns !==
null && !in_array( $row->page_namespace, $miser_ns ) ) {
233 if ( $resultPageSet !==
null ) {
234 if (
$params[
'generatetitles'] ) {
235 $generated[$row->rev_page] = $row->rev_page;
237 $generated[] = $row->rev_id;
240 $revision = $this->revisionStore->newRevisionFromRow( $row, 0, Title::newFromRow( $row ) );
243 if ( !isset( $pageMap[$row->rev_page] ) ) {
244 $index = $nextIndex++;
245 $pageMap[$row->rev_page] = $index;
246 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
248 'pageid' => $title->getArticleID(),
249 'revisions' => [ $rev ],
253 $fit = $this->
processRow( $row, $a[
'revisions'][0], $hookData ) &&
254 $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
256 $index = $pageMap[$row->rev_page];
257 $fit = $this->
processRow( $row, $rev, $hookData ) &&
258 $result->addValue( [
'query', $this->
getModuleName(), $index,
'revisions' ],
null, $rev );
267 if ( $resultPageSet !==
null ) {
268 if (
$params[
'generatetitles'] ) {
269 $resultPageSet->populateFromPageIDs( $generated );
271 $resultPageSet->populateFromRevisionIDs( $generated );
274 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
279 $ret = parent::getAllowedParams() + [
281 ParamValidator::PARAM_TYPE =>
'user',
282 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
283 UserDef::PARAM_RETURN_OBJECT =>
true,
286 ParamValidator::PARAM_ISMULTI =>
true,
287 ParamValidator::PARAM_TYPE =>
'namespace',
288 ParamValidator::PARAM_DEFAULT =>
null,
291 ParamValidator::PARAM_TYPE =>
'timestamp',
294 ParamValidator::PARAM_TYPE =>
'timestamp',
297 ParamValidator::PARAM_TYPE => [
301 ParamValidator::PARAM_DEFAULT =>
'older',
304 'newer' =>
'api-help-paramvalue-direction-newer',
305 'older' =>
'api-help-paramvalue-direction-older',
309 ParamValidator::PARAM_TYPE =>
'user',
310 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
311 UserDef::PARAM_RETURN_OBJECT =>
true,
316 'generatetitles' => [
317 ParamValidator::PARAM_DEFAULT =>
false,
323 'api-help-param-limited-in-miser-mode',
332 'action=query&list=allrevisions&arvuser=Example&arvlimit=50'
333 =>
'apihelp-query+allrevisions-example-user',
334 'action=query&list=allrevisions&arvdir=newer&arvlimit=50'
335 =>
'apihelp-query+allrevisions-example-ns-any',
340 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allrevisions';
345class_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()