63 $contentHandlerFactory,
85 if ( $params[
'namespace'] === [] ) {
86 if ( $resultPageSet ===
null ) {
96 if ( $params[
'user'] !==
null ) {
100 if ( $mode ==
'user' ) {
101 foreach ( [
'from',
'to',
'prefix',
'excludeuser' ] as $param ) {
102 if ( $params[$param] !==
null ) {
105 [
'apierror-invalidparammix-cannotusewith', $p . $param,
"{$p}user" ],
111 foreach ( [
'start',
'end' ] as $param ) {
112 if ( $params[$param] !==
null ) {
115 [
'apierror-invalidparammix-mustusewith', $p . $param,
"{$p}user" ],
126 $dir = $params[
'dir'];
127 $optimizeGenerateTitles =
false;
128 if ( $mode ===
'all' && $params[
'generatetitles'] && $resultPageSet !==
null ) {
129 if ( $dir ===
'newer' ) {
130 $optimizeGenerateTitles =
true;
133 $this->
addWarning( [
'apiwarn-alldeletedrevisions-performance', $p ],
'performance' );
137 if ( $resultPageSet ===
null ) {
139 $arQuery = $this->revisionStore->getArchiveQueryInfo();
143 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
147 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
148 if ( $optimizeGenerateTitles ) {
151 $this->
addFields( [
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
153 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
155 $this->
addJoinConds( [
'actor' =>
'actor_id=ar_actor' ] );
159 if ( $this->fld_tags ) {
161 'ts_tags' => $this->changeTagsStore->makeTagSummarySubquery(
'archive' )
165 if ( $params[
'tag'] !==
null ) {
168 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
171 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
179 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
182 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
184 if ( $this->fetchContent &&
185 !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' )
187 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
192 if ( $mode ==
'all' ) {
193 $namespaces = $params[
'namespace'] ?? $this->namespaceInfo->getValidNamespaces();
200 if ( $params[
'from'] !==
null || $params[
'to'] !==
null ) {
201 $isDirNewer = ( $dir ===
'newer' );
202 $after = ( $isDirNewer ?
'>=' :
'<=' );
203 $before = ( $isDirNewer ?
'<=' :
'>=' );
205 foreach ( $namespaces as $ns ) {
206 if ( $params[
'from'] !==
null ) {
211 if ( $params[
'to'] !==
null ) {
216 $titleParts[$fromTitlePart .
'|' . $toTitlePart][] = $ns;
218 if ( count( $titleParts ) === 1 ) {
219 [ $fromTitlePart, $toTitlePart, ] = explode(
'|', key( $titleParts ), 2 );
220 if ( $fromTitlePart !==
'' ) {
221 $this->
addWhere( $db->expr(
'ar_title', $after, $fromTitlePart ) );
223 if ( $toTitlePart !==
'' ) {
224 $this->
addWhere( $db->expr(
'ar_title', $before, $toTitlePart ) );
228 foreach ( $titleParts as $titlePart => $ns ) {
229 [ $fromTitlePart, $toTitlePart, ] = explode(
'|', $titlePart, 2 );
230 $expr = $db->expr(
'ar_namespace',
'=', $ns );
231 if ( $fromTitlePart !==
'' ) {
232 $expr = $expr->and(
'ar_title', $after, $fromTitlePart );
234 if ( $toTitlePart !==
'' ) {
235 $expr = $expr->and(
'ar_title', $before, $toTitlePart );
239 $this->
addWhere( $db->orExpr( $where ) );
243 if ( isset( $params[
'prefix'] ) ) {
245 foreach ( $namespaces as $ns ) {
246 $prefixTitlePart = $this->
titlePartToKey( $params[
'prefix'], $ns );
247 $titleParts[$prefixTitlePart][] = $ns;
249 if ( count( $titleParts ) === 1 ) {
250 $prefixTitlePart = key( $titleParts );
251 $this->
addWhere( $db->expr(
'ar_title', IExpression::LIKE,
252 new LikeValue( $prefixTitlePart, $db->anyString() )
256 foreach ( $titleParts as $prefixTitlePart => $ns ) {
257 $where[] = $db->expr(
'ar_namespace',
'=', $ns )
258 ->and(
'ar_title', IExpression::LIKE,
259 new LikeValue( $prefixTitlePart, $db->anyString() ) );
261 $this->
addWhere( $db->orExpr( $where ) );
266 $miser_ns = $params[
'namespace'];
268 $this->
addWhereFld(
'ar_namespace', $params[
'namespace'] );
273 if ( $params[
'user'] !==
null ) {
278 $this->
addWhereFld(
'actor_name', $params[
'user'] );
279 } elseif ( $params[
'excludeuser'] !==
null ) {
280 $this->
addWhere( $db->expr(
'actor_name',
'!=', $params[
'excludeuser'] ) );
283 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
285 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
286 $bitmask = RevisionRecord::DELETED_USER;
287 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
288 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
293 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
297 if ( $params[
'continue'] !==
null ) {
298 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
299 if ( $optimizeGenerateTitles ) {
301 $this->
addWhere( $db->buildComparison( $op, [
302 'ar_namespace' => $cont[0],
303 'ar_title' => $cont[1],
305 } elseif ( $mode ==
'all' ) {
307 $this->
addWhere( $db->buildComparison( $op, [
308 'ar_namespace' => $cont[0],
309 'ar_title' => $cont[1],
310 'ar_timestamp' => $db->timestamp( $cont[2] ),
315 $this->
addWhere( $db->buildComparison( $op, [
316 'ar_timestamp' => $db->timestamp( $cont[0] ),
322 $this->
addOption(
'LIMIT', $this->limit + 1 );
324 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
326 if ( $optimizeGenerateTitles ) {
328 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
329 $orderby[] =
"ar_namespace $sort";
331 $orderby[] =
"ar_title $sort";
332 } elseif ( $mode ==
'all' ) {
334 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
335 $orderby[] =
"ar_namespace $sort";
337 $orderby[] =
"ar_title $sort";
338 $orderby[] =
"ar_timestamp $sort";
339 $orderby[] =
"ar_id $sort";
343 $orderby[] =
"ar_timestamp $sort";
344 $orderby[] =
"ar_id $sort";
346 $this->
addOption(
'ORDER BY', $orderby );
348 $res = $this->
select( __METHOD__ );
350 if ( $resultPageSet ===
null ) {
358 foreach ( $res as $row ) {
359 if ( ++$count > $this->limit ) {
361 if ( $optimizeGenerateTitles ) {
363 } elseif ( $mode ==
'all' ) {
365 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
374 if ( $miser_ns !==
null && !in_array( $row->ar_namespace, $miser_ns ) ) {
378 if ( $resultPageSet !==
null ) {
379 if ( $params[
'generatetitles'] ) {
380 $key =
"{$row->ar_namespace}:{$row->ar_title}";
381 if ( !isset( $generated[$key] ) ) {
385 $generated[] = $row->ar_rev_id;
388 $revision = $this->revisionStore->newRevisionFromArchiveRow( $row );
391 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
392 $index = $nextIndex++;
393 $pageMap[$row->ar_namespace][$row->ar_title] = $index;
394 $title = Title::newFromPageIdentity( $revision->getPage() );
396 'pageid' => $title->getArticleID(),
397 'revisions' => [ $rev ],
401 $fit = $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
403 $index = $pageMap[$row->ar_namespace][$row->ar_title];
404 $fit = $result->addValue(
409 if ( $mode ==
'all' ) {
411 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
421 if ( $resultPageSet !==
null ) {
422 if ( $params[
'generatetitles'] ) {
423 $resultPageSet->populateFromTitles( $generated );
425 $resultPageSet->populateFromRevisionIDs( $generated );
428 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
434 $ret = parent::getAllowedParams() + [
436 ParamValidator::PARAM_TYPE =>
'user',
437 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
440 ParamValidator::PARAM_ISMULTI =>
true,
441 ParamValidator::PARAM_TYPE =>
'namespace',
444 ParamValidator::PARAM_TYPE =>
'timestamp',
448 ParamValidator::PARAM_TYPE =>
'timestamp',
452 ParamValidator::PARAM_TYPE => [
456 ParamValidator::PARAM_DEFAULT =>
'older',
459 'newer' =>
'api-help-paramvalue-direction-newer',
460 'older' =>
'api-help-paramvalue-direction-older',
473 ParamValidator::PARAM_TYPE =>
'user',
474 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
481 'generatetitles' => [
482 ParamValidator::PARAM_DEFAULT => false
488 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
491 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
501 'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50'
502 =>
'apihelp-query+alldeletedrevisions-example-user',
503 'action=query&list=alldeletedrevisions&adrdir=newer&adrnamespace=0&adrlimit=50'
504 =>
'apihelp-query+alldeletedrevisions-example-ns-main',
510 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Alldeletedrevisions';
515class_alias( ApiQueryAllDeletedRevisions::class,
'ApiQueryAllDeletedRevisions' );
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()