47 private $revisionStore;
50 private $changeTagDefStore;
53 private $namespaceInfo;
86 $contentHandlerFactory,
93 $this->revisionStore = $revisionStore;
94 $this->changeTagDefStore = $changeTagDefStore;
95 $this->namespaceInfo = $namespaceInfo;
103 $db = $this->
getDB();
109 if ( $params[
'namespace'] === [] ) {
110 if ( $resultPageSet ===
null ) {
120 if ( $params[
'user'] !==
null ) {
124 if ( $mode ==
'user' ) {
125 foreach ( [
'from',
'to',
'prefix',
'excludeuser' ] as $param ) {
126 if ( $params[$param] !==
null ) {
129 [
'apierror-invalidparammix-cannotusewith', $p . $param,
"{$p}user" ],
135 foreach ( [
'start',
'end' ] as $param ) {
136 if ( $params[$param] !==
null ) {
139 [
'apierror-invalidparammix-mustusewith', $p . $param,
"{$p}user" ],
150 $dir = $params[
'dir'];
151 $optimizeGenerateTitles =
false;
152 if ( $mode ===
'all' && $params[
'generatetitles'] && $resultPageSet !==
null ) {
153 if ( $dir ===
'newer' ) {
154 $optimizeGenerateTitles =
true;
157 $this->
addWarning( [
'apiwarn-alldeletedrevisions-performance', $p ],
'performance' );
161 if ( $resultPageSet ===
null ) {
163 $arQuery = $this->revisionStore->getArchiveQueryInfo();
167 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
171 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
172 if ( $optimizeGenerateTitles ) {
175 $this->
addFields( [
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
177 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
179 $this->
addJoinConds( [
'actor' =>
'actor_id=ar_actor' ] );
183 if ( $this->fld_tags ) {
187 if ( $params[
'tag'] !==
null ) {
190 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
193 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
201 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
204 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
206 if ( $this->fetchContent &&
207 !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' )
209 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
214 if ( $mode ==
'all' ) {
215 $namespaces = $params[
'namespace'] ?? $this->namespaceInfo->getValidNamespaces();
222 if ( $params[
'from'] !==
null || $params[
'to'] !==
null ) {
223 $isDirNewer = ( $dir ===
'newer' );
224 $after = ( $isDirNewer ?
'>=' :
'<=' );
225 $before = ( $isDirNewer ?
'<=' :
'>=' );
227 foreach ( $namespaces as $ns ) {
229 if ( $params[
'from'] !==
null ) {
230 $w[] =
'ar_title' . $after .
233 if ( $params[
'to'] !==
null ) {
234 $w[] =
'ar_title' . $before .
240 if ( count( $where ) == 1 ) {
241 $where = key( $where );
245 foreach ( $where as $w => $ns ) {
246 $where2[] = $db->makeList( [ $w,
'ar_namespace' => $ns ],
LIST_AND );
252 if ( isset( $params[
'prefix'] ) ) {
254 foreach ( $namespaces as $ns ) {
255 $w =
'ar_title' . $db->buildLike(
260 if ( count( $where ) == 1 ) {
261 $where = key( $where );
265 foreach ( $where as $w => $ns ) {
266 $where2[] = $db->makeList( [ $w,
'ar_namespace' => $ns ],
LIST_AND );
272 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
273 $miser_ns = $params[
'namespace'];
275 $this->
addWhereFld(
'ar_namespace', $params[
'namespace'] );
280 if ( $params[
'user'] !==
null ) {
285 $this->
addWhereFld(
'actor_name', $params[
'user'] );
286 } elseif ( $params[
'excludeuser'] !==
null ) {
287 $this->
addWhere(
'actor_name<>' . $db->addQuotes( $params[
'excludeuser'] ) );
290 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
292 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
293 $bitmask = RevisionRecord::DELETED_USER;
294 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
295 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
300 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
304 if ( $params[
'continue'] !==
null ) {
305 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
306 if ( $optimizeGenerateTitles ) {
308 $this->
addWhere( $db->buildComparison( $op, [
309 'ar_namespace' => $cont[0],
310 'ar_title' => $cont[1],
312 } elseif ( $mode ==
'all' ) {
314 $this->
addWhere( $db->buildComparison( $op, [
315 'ar_namespace' => $cont[0],
316 'ar_title' => $cont[1],
317 'ar_timestamp' => $db->timestamp( $cont[2] ),
322 $this->
addWhere( $db->buildComparison( $op, [
323 'ar_timestamp' => $db->timestamp( $cont[0] ),
329 $this->
addOption(
'LIMIT', $this->limit + 1 );
331 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
333 if ( $optimizeGenerateTitles ) {
335 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
336 $orderby[] =
"ar_namespace $sort";
338 $orderby[] =
"ar_title $sort";
339 } elseif ( $mode ==
'all' ) {
341 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
342 $orderby[] =
"ar_namespace $sort";
344 $orderby[] =
"ar_title $sort";
345 $orderby[] =
"ar_timestamp $sort";
346 $orderby[] =
"ar_id $sort";
350 $orderby[] =
"ar_timestamp $sort";
351 $orderby[] =
"ar_id $sort";
353 $this->
addOption(
'ORDER BY', $orderby );
357 if ( $resultPageSet ===
null ) {
365 foreach (
$res as $row ) {
366 if ( ++$count > $this->limit ) {
368 if ( $optimizeGenerateTitles ) {
370 } elseif ( $mode ==
'all' ) {
372 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
381 if ( $miser_ns !==
null && !in_array( $row->ar_namespace, $miser_ns ) ) {
385 if ( $resultPageSet !==
null ) {
386 if ( $params[
'generatetitles'] ) {
387 $key =
"{$row->ar_namespace}:{$row->ar_title}";
388 if ( !isset( $generated[$key] ) ) {
392 $generated[] = $row->ar_rev_id;
395 $revision = $this->revisionStore->newRevisionFromArchiveRow( $row );
398 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
399 $index = $nextIndex++;
400 $pageMap[$row->ar_namespace][$row->ar_title] = $index;
403 'pageid' =>
$title->getArticleID(),
404 'revisions' => [ $rev ],
408 $fit = $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
410 $index = $pageMap[$row->ar_namespace][$row->ar_title];
411 $fit = $result->addValue(
416 if ( $mode ==
'all' ) {
418 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
428 if ( $resultPageSet !==
null ) {
429 if ( $params[
'generatetitles'] ) {
430 $resultPageSet->populateFromTitles( $generated );
432 $resultPageSet->populateFromRevisionIDs( $generated );
435 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
440 $ret = parent::getAllowedParams() + [
442 ParamValidator::PARAM_TYPE =>
'user',
443 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
446 ParamValidator::PARAM_ISMULTI =>
true,
447 ParamValidator::PARAM_TYPE =>
'namespace',
450 ParamValidator::PARAM_TYPE =>
'timestamp',
454 ParamValidator::PARAM_TYPE =>
'timestamp',
458 ParamValidator::PARAM_TYPE => [
462 ParamValidator::PARAM_DEFAULT =>
'older',
475 ParamValidator::PARAM_TYPE =>
'user',
476 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
483 'generatetitles' => [
484 ParamValidator::PARAM_DEFAULT => false
488 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
490 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
493 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
502 'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50'
503 =>
'apihelp-query+alldeletedrevisions-example-user',
504 'action=query&list=alldeletedrevisions&adrdir=newer&adrnamespace=0&adrlimit=50'
505 =>
'apihelp-query+alldeletedrevisions-example-ns-main',
510 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.
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 ...
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
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.
getAllowedParams()
@stable to override
getHelpUrls()
Return links to more detailed help pages about the module.
run(ApiPageSet $resultPageSet=null)
__construct(ApiQuery $query, $moduleName, RevisionStore $revisionStore, IContentHandlerFactory $contentHandlerFactory, ParserFactory $parserFactory, SlotRoleRegistry $slotRoleRegistry, NameTableStore $changeTagDefStore, NamespaceInfo $namespaceInfo, ContentRenderer $contentRenderer, ContentTransformer $contentTransformer, CommentFormatter $commentFormatter)
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.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
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...
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.