80 $contentHandlerFactory,
89 $this->revisionStore = $revisionStore;
90 $this->changeTagDefStore = $changeTagDefStore;
91 $this->namespaceInfo = $namespaceInfo;
105 if (
$params[
'namespace'] === [] ) {
106 if ( $resultPageSet ===
null ) {
116 if (
$params[
'user'] !==
null ) {
120 if ( $mode ==
'user' ) {
121 foreach ( [
'from',
'to',
'prefix',
'excludeuser' ] as $param ) {
122 if (
$params[$param] !==
null ) {
125 [
'apierror-invalidparammix-cannotusewith', $p . $param,
"{$p}user" ],
131 foreach ( [
'start',
'end' ] as $param ) {
132 if (
$params[$param] !==
null ) {
135 [
'apierror-invalidparammix-mustusewith', $p . $param,
"{$p}user" ],
147 $optimizeGenerateTitles =
false;
148 if ( $mode ===
'all' &&
$params[
'generatetitles'] && $resultPageSet !==
null ) {
149 if ( $dir ===
'newer' ) {
150 $optimizeGenerateTitles =
true;
153 $this->
addWarning( [
'apiwarn-alldeletedrevisions-performance', $p ],
'performance' );
157 if ( $resultPageSet ===
null ) {
159 $arQuery = $this->revisionStore->getArchiveQueryInfo();
163 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
167 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
168 if ( $optimizeGenerateTitles ) {
171 $this->
addFields( [
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
173 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
175 $this->
addJoinConds( [
'actor' =>
'actor_id=ar_actor' ] );
179 if ( $this->fld_tags ) {
182 ->makeTagSummarySubquery(
'archive' )
186 if (
$params[
'tag'] !==
null ) {
189 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
200 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
203 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
205 if ( $this->fetchContent &&
206 !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' )
208 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
213 if ( $mode ==
'all' ) {
214 $namespaces =
$params[
'namespace'] ?? $this->namespaceInfo->getValidNamespaces();
222 $isDirNewer = ( $dir ===
'newer' );
223 $after = ( $isDirNewer ?
'>=' :
'<=' );
224 $before = ( $isDirNewer ?
'<=' :
'>=' );
226 foreach ( $namespaces as $ns ) {
227 if (
$params[
'from'] !==
null ) {
232 if (
$params[
'to'] !==
null ) {
237 $titleParts[$fromTitlePart .
'|' . $toTitlePart][] = $ns;
239 if ( count( $titleParts ) === 1 ) {
240 [ $fromTitlePart, $toTitlePart, ] = explode(
'|', key( $titleParts ), 2 );
241 if ( $fromTitlePart !==
'' ) {
242 $this->
addWhere( $db->expr(
'ar_title', $after, $fromTitlePart ) );
244 if ( $toTitlePart !==
'' ) {
245 $this->
addWhere( $db->expr(
'ar_title', $before, $toTitlePart ) );
249 foreach ( $titleParts as $titlePart => $ns ) {
250 [ $fromTitlePart, $toTitlePart, ] = explode(
'|', $titlePart, 2 );
251 $expr = $db->expr(
'ar_namespace',
'=', $ns );
252 if ( $fromTitlePart !==
'' ) {
253 $expr = $expr->and(
'ar_title', $after, $fromTitlePart );
255 if ( $toTitlePart !==
'' ) {
256 $expr = $expr->and(
'ar_title', $before, $toTitlePart );
260 $this->
addWhere( $db->orExpr( $where ) );
264 if ( isset(
$params[
'prefix'] ) ) {
266 foreach ( $namespaces as $ns ) {
268 $titleParts[$prefixTitlePart][] = $ns;
270 if ( count( $titleParts ) === 1 ) {
271 $prefixTitlePart = key( $titleParts );
272 $this->
addWhere( $db->expr(
'ar_title', IExpression::LIKE,
273 new LikeValue( $prefixTitlePart, $db->anyString() )
277 foreach ( $titleParts as $prefixTitlePart => $ns ) {
278 $where[] = $db->expr(
'ar_namespace',
'=', $ns )
279 ->and(
'ar_title', IExpression::LIKE,
280 new LikeValue( $prefixTitlePart, $db->anyString() ) );
282 $this->
addWhere( $db->orExpr( $where ) );
287 $miser_ns =
$params[
'namespace'];
294 if (
$params[
'user'] !==
null ) {
300 } elseif (
$params[
'excludeuser'] !==
null ) {
301 $this->
addWhere( $db->expr(
'actor_name',
'!=',
$params[
'excludeuser'] ) );
304 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
306 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
307 $bitmask = RevisionRecord::DELETED_USER;
308 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
309 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
314 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
318 if (
$params[
'continue'] !==
null ) {
319 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
320 if ( $optimizeGenerateTitles ) {
322 $this->
addWhere( $db->buildComparison( $op, [
323 'ar_namespace' => $cont[0],
324 'ar_title' => $cont[1],
326 } elseif ( $mode ==
'all' ) {
328 $this->
addWhere( $db->buildComparison( $op, [
329 'ar_namespace' => $cont[0],
330 'ar_title' => $cont[1],
331 'ar_timestamp' => $db->timestamp( $cont[2] ),
336 $this->
addWhere( $db->buildComparison( $op, [
337 'ar_timestamp' => $db->timestamp( $cont[0] ),
343 $this->
addOption(
'LIMIT', $this->limit + 1 );
345 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
347 if ( $optimizeGenerateTitles ) {
349 if (
$params[
'namespace'] ===
null || count( array_unique(
$params[
'namespace'] ) ) > 1 ) {
350 $orderby[] =
"ar_namespace $sort";
352 $orderby[] =
"ar_title $sort";
353 } elseif ( $mode ==
'all' ) {
355 if (
$params[
'namespace'] ===
null || count( array_unique(
$params[
'namespace'] ) ) > 1 ) {
356 $orderby[] =
"ar_namespace $sort";
358 $orderby[] =
"ar_title $sort";
359 $orderby[] =
"ar_timestamp $sort";
360 $orderby[] =
"ar_id $sort";
364 $orderby[] =
"ar_timestamp $sort";
365 $orderby[] =
"ar_id $sort";
367 $this->
addOption(
'ORDER BY', $orderby );
369 $res = $this->
select( __METHOD__ );
371 if ( $resultPageSet ===
null ) {
379 foreach ( $res as $row ) {
380 if ( ++$count > $this->limit ) {
382 if ( $optimizeGenerateTitles ) {
384 } elseif ( $mode ==
'all' ) {
386 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
395 if ( $miser_ns !==
null && !in_array( $row->ar_namespace, $miser_ns ) ) {
399 if ( $resultPageSet !==
null ) {
400 if (
$params[
'generatetitles'] ) {
401 $key =
"{$row->ar_namespace}:{$row->ar_title}";
402 if ( !isset( $generated[$key] ) ) {
403 $generated[$key] = Title::makeTitle( $row->ar_namespace, $row->ar_title );
406 $generated[] = $row->ar_rev_id;
409 $revision = $this->revisionStore->newRevisionFromArchiveRow( $row );
412 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
413 $index = $nextIndex++;
414 $pageMap[$row->ar_namespace][$row->ar_title] = $index;
415 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
417 'pageid' => $title->getArticleID(),
418 'revisions' => [ $rev ],
422 $fit = $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
424 $index = $pageMap[$row->ar_namespace][$row->ar_title];
425 $fit = $result->addValue(
430 if ( $mode ==
'all' ) {
432 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
442 if ( $resultPageSet !==
null ) {
443 if (
$params[
'generatetitles'] ) {
444 $resultPageSet->populateFromTitles( $generated );
446 $resultPageSet->populateFromRevisionIDs( $generated );
449 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
454 $ret = parent::getAllowedParams() + [
456 ParamValidator::PARAM_TYPE =>
'user',
457 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
460 ParamValidator::PARAM_ISMULTI =>
true,
461 ParamValidator::PARAM_TYPE =>
'namespace',
464 ParamValidator::PARAM_TYPE =>
'timestamp',
468 ParamValidator::PARAM_TYPE =>
'timestamp',
472 ParamValidator::PARAM_TYPE => [
476 ParamValidator::PARAM_DEFAULT =>
'older',
479 'newer' =>
'api-help-paramvalue-direction-newer',
480 'older' =>
'api-help-paramvalue-direction-older',
493 ParamValidator::PARAM_TYPE =>
'user',
494 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
501 'generatetitles' => [
502 ParamValidator::PARAM_DEFAULT => false
508 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
511 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
520 'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50'
521 =>
'apihelp-query+alldeletedrevisions-example-user',
522 'action=query&list=alldeletedrevisions&adrdir=newer&adrnamespace=0&adrlimit=50'
523 =>
'apihelp-query+alldeletedrevisions-example-ns-main',
528 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Alldeletedrevisions';
533class_alias( ApiQueryAllDeletedRevisions::class,
'ApiQueryAllDeletedRevisions' );
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()