46 private $revisionStore;
49 private $changeTagDefStore;
52 private $namespaceInfo;
83 $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" ],
146 $dir = $params[
'dir'];
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 ) {
183 if ( $params[
'tag'] !==
null ) {
186 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
189 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
197 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
200 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
202 if ( $this->fetchContent &&
203 !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' )
205 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
210 if ( $mode ==
'all' ) {
211 $namespaces = $params[
'namespace'] ?? $this->namespaceInfo->getValidNamespaces();
218 if ( $params[
'from'] !==
null || $params[
'to'] !==
null ) {
219 $isDirNewer = ( $dir ===
'newer' );
220 $after = ( $isDirNewer ?
'>=' :
'<=' );
221 $before = ( $isDirNewer ?
'<=' :
'>=' );
223 foreach ( $namespaces as $ns ) {
225 if ( $params[
'from'] !==
null ) {
226 $w[] =
'ar_title' . $after .
229 if ( $params[
'to'] !==
null ) {
230 $w[] =
'ar_title' . $before .
236 if ( count( $where ) == 1 ) {
237 $where = key( $where );
241 foreach ( $where as $w => $ns ) {
242 $where2[] = $db->makeList( [ $w,
'ar_namespace' => $ns ],
LIST_AND );
248 if ( isset( $params[
'prefix'] ) ) {
250 foreach ( $namespaces as $ns ) {
251 $w =
'ar_title' . $db->buildLike(
256 if ( count( $where ) == 1 ) {
257 $where = key( $where );
261 foreach ( $where as $w => $ns ) {
262 $where2[] = $db->makeList( [ $w,
'ar_namespace' => $ns ],
LIST_AND );
268 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
269 $miser_ns = $params[
'namespace'];
271 $this->
addWhereFld(
'ar_namespace', $params[
'namespace'] );
276 if ( $params[
'user'] !==
null ) {
281 $this->
addWhereFld(
'actor_name', $params[
'user'] );
282 } elseif ( $params[
'excludeuser'] !==
null ) {
283 $this->
addWhere(
'actor_name<>' . $db->addQuotes( $params[
'excludeuser'] ) );
286 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
288 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
289 $bitmask = RevisionRecord::DELETED_USER;
290 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
291 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
296 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
300 if ( $params[
'continue'] !==
null ) {
301 $cont = explode(
'|', $params[
'continue'] );
302 $op = ( $dir ==
'newer' ?
'>' :
'<' );
303 if ( $optimizeGenerateTitles ) {
307 $title = $db->addQuotes( $cont[1] );
308 $this->
addWhere(
"ar_namespace $op $ns OR " .
309 "(ar_namespace = $ns AND ar_title $op= $title)" );
310 } elseif ( $mode ==
'all' ) {
314 $title = $db->addQuotes( $cont[1] );
315 $ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
316 $ar_id = (int)$cont[3];
318 $this->
addWhere(
"ar_namespace $op $ns OR " .
319 "(ar_namespace = $ns AND " .
320 "(ar_title $op $title OR " .
321 "(ar_title = $title AND " .
322 "(ar_timestamp $op $ts OR " .
323 "(ar_timestamp = $ts AND " .
324 "ar_id $op= $ar_id)))))" );
327 $ts = $db->addQuotes( $db->timestamp( $cont[0] ) );
328 $ar_id = (int)$cont[1];
330 $this->
addWhere(
"ar_timestamp $op $ts OR " .
331 "(ar_timestamp = $ts AND " .
332 "ar_id $op= $ar_id)" );
336 $this->
addOption(
'LIMIT', $this->limit + 1 );
338 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
340 if ( $optimizeGenerateTitles ) {
342 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
343 $orderby[] =
"ar_namespace $sort";
345 $orderby[] =
"ar_title $sort";
346 } elseif ( $mode ==
'all' ) {
348 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
349 $orderby[] =
"ar_namespace $sort";
351 $orderby[] =
"ar_title $sort";
352 $orderby[] =
"ar_timestamp $sort";
353 $orderby[] =
"ar_id $sort";
357 $orderby[] =
"ar_timestamp $sort";
358 $orderby[] =
"ar_id $sort";
360 $this->
addOption(
'ORDER BY', $orderby );
364 if ( $resultPageSet ===
null ) {
372 foreach (
$res as $row ) {
373 if ( ++$count > $this->limit ) {
375 if ( $optimizeGenerateTitles ) {
377 } elseif ( $mode ==
'all' ) {
379 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
388 if ( $miser_ns !==
null && !in_array( $row->ar_namespace, $miser_ns ) ) {
392 if ( $resultPageSet !==
null ) {
393 if ( $params[
'generatetitles'] ) {
394 $key =
"{$row->ar_namespace}:{$row->ar_title}";
395 if ( !isset( $generated[$key] ) ) {
396 $generated[$key] = Title::makeTitle( $row->ar_namespace, $row->ar_title );
399 $generated[] = $row->ar_rev_id;
402 $revision = $this->revisionStore->newRevisionFromArchiveRow( $row );
405 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
406 $index = $nextIndex++;
407 $pageMap[$row->ar_namespace][$row->ar_title] = $index;
408 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
410 'pageid' =>
$title->getArticleID(),
411 'revisions' => [ $rev ],
413 ApiResult::setIndexedTagName( $a[
'revisions'],
'rev' );
415 $fit = $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
417 $index = $pageMap[$row->ar_namespace][$row->ar_title];
418 $fit = $result->addValue(
423 if ( $mode ==
'all' ) {
425 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
435 if ( $resultPageSet !==
null ) {
436 if ( $params[
'generatetitles'] ) {
437 $resultPageSet->populateFromTitles( $generated );
439 $resultPageSet->populateFromRevisionIDs( $generated );
442 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
447 $ret = parent::getAllowedParams() + [
449 ParamValidator::PARAM_TYPE =>
'user',
450 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
453 ParamValidator::PARAM_ISMULTI =>
true,
454 ParamValidator::PARAM_TYPE =>
'namespace',
457 ParamValidator::PARAM_TYPE =>
'timestamp',
461 ParamValidator::PARAM_TYPE =>
'timestamp',
465 ParamValidator::PARAM_TYPE => [
469 ParamValidator::PARAM_DEFAULT =>
'older',
472 'newer' =>
'api-help-paramvalue-direction-newer',
473 'older' =>
'api-help-paramvalue-direction-older',
486 ParamValidator::PARAM_TYPE =>
'user',
487 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
494 'generatetitles' => [
495 ParamValidator::PARAM_DEFAULT => false
499 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
501 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
504 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
513 'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50'
514 =>
'apihelp-query+alldeletedrevisions-example-user',
515 'action=query&list=alldeletedrevisions&adrdir=newer&adrnamespace=0&adrlimit=50'
516 =>
'apihelp-query+alldeletedrevisions-example-ns-main',
521 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Alldeletedrevisions';
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
getModuleName()
Get the name of the module being executed by this instance.
This class contains a list of pages that the client has requested.
Query module to enumerate all deleted revisions.
getExamplesMessages()
Returns usage examples for this module.
getHelpUrls()
Return links to more detailed help pages about the module.
__construct(ApiQuery $query, $moduleName, RevisionStore $revisionStore, IContentHandlerFactory $contentHandlerFactory, ParserFactory $parserFactory, SlotRoleRegistry $slotRoleRegistry, NameTableStore $changeTagDefStore, NamespaceInfo $namespaceInfo, ContentRenderer $contentRenderer, ContentTransformer $contentTransformer)
run(ApiPageSet $resultPageSet=null)
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
getDB()
Get the Query database connection (read-only)
executeGenderCacheFromResultWrapper(IResultWrapper $res, $fname=__METHOD__, $fieldPrefix='page')
Preprocess the result set to fill the GenderCache with the necessary information before using self::a...
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
titlePartToKey( $titlePart, $namespace=NS_MAIN)
Convert an input title or title prefix into a dbkey.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
A base class for functions common to producing a list of revisions.
parseParameters( $params)
Parse the parameters into the various instance fields.
extractRevisionInfo(RevisionRecord $revision, $row)
Extract information from the RevisionRecord.
This is the main query class.
A service to render content.
A service to transform content.
A class containing constants representing the names of configuration variables.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...