89 $contentHandlerFactory,
98 $this->revisionStore = $revisionStore;
99 $this->changeTagDefStore = $changeTagDefStore;
100 $this->namespaceInfo = $namespaceInfo;
108 $db = $this->
getDB();
114 if ( $params[
'namespace'] === [] ) {
115 if ( $resultPageSet ===
null ) {
125 if ( $params[
'user'] !==
null ) {
129 if ( $mode ==
'user' ) {
130 foreach ( [
'from',
'to',
'prefix',
'excludeuser' ] as $param ) {
131 if ( $params[$param] !==
null ) {
134 [
'apierror-invalidparammix-cannotusewith', $p . $param,
"{$p}user" ],
140 foreach ( [
'start',
'end' ] as $param ) {
141 if ( $params[$param] !==
null ) {
144 [
'apierror-invalidparammix-mustusewith', $p . $param,
"{$p}user" ],
155 $dir = $params[
'dir'];
156 $optimizeGenerateTitles =
false;
157 if ( $mode ===
'all' && $params[
'generatetitles'] && $resultPageSet !==
null ) {
158 if ( $dir ===
'newer' ) {
159 $optimizeGenerateTitles =
true;
162 $this->
addWarning( [
'apiwarn-alldeletedrevisions-performance', $p ],
'performance' );
166 if ( $resultPageSet ===
null ) {
168 $arQuery = $this->revisionStore->getArchiveQueryInfo();
172 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
176 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
177 if ( $optimizeGenerateTitles ) {
180 $this->
addFields( [
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
182 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
184 $this->
addJoinConds( [
'actor' =>
'actor_id=ar_actor' ] );
188 if ( $this->fld_tags ) {
192 if ( $params[
'tag'] !==
null ) {
195 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
198 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
206 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
209 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
211 if ( $this->fetchContent &&
212 !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' )
214 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
219 if ( $mode ==
'all' ) {
220 $namespaces = $params[
'namespace'] ?? $this->namespaceInfo->getValidNamespaces();
227 if ( $params[
'from'] !==
null || $params[
'to'] !==
null ) {
228 $isDirNewer = ( $dir ===
'newer' );
229 $after = ( $isDirNewer ?
'>=' :
'<=' );
230 $before = ( $isDirNewer ?
'<=' :
'>=' );
232 foreach ( $namespaces as $ns ) {
234 if ( $params[
'from'] !==
null ) {
235 $w[] =
'ar_title' . $after .
238 if ( $params[
'to'] !==
null ) {
239 $w[] =
'ar_title' . $before .
245 if ( count( $where ) == 1 ) {
246 $where = key( $where );
250 foreach ( $where as $w => $ns ) {
251 $where2[] = $db->makeList( [ $w,
'ar_namespace' => $ns ],
LIST_AND );
257 if ( isset( $params[
'prefix'] ) ) {
259 foreach ( $namespaces as $ns ) {
260 $w =
'ar_title' . $db->buildLike(
265 if ( count( $where ) == 1 ) {
266 $where = key( $where );
270 foreach ( $where as $w => $ns ) {
271 $where2[] = $db->makeList( [ $w,
'ar_namespace' => $ns ],
LIST_AND );
277 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
278 $miser_ns = $params[
'namespace'];
280 $this->
addWhereFld(
'ar_namespace', $params[
'namespace'] );
285 if ( $params[
'user'] !==
null ) {
290 $this->
addWhereFld(
'actor_name', $params[
'user'] );
291 } elseif ( $params[
'excludeuser'] !==
null ) {
292 $this->
addWhere(
'actor_name<>' . $db->addQuotes( $params[
'excludeuser'] ) );
295 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
297 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
298 $bitmask = RevisionRecord::DELETED_USER;
299 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
300 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
305 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
309 if ( $params[
'continue'] !==
null ) {
310 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
311 if ( $optimizeGenerateTitles ) {
313 $this->
addWhere( $db->buildComparison( $op, [
314 'ar_namespace' => $cont[0],
315 'ar_title' => $cont[1],
317 } elseif ( $mode ==
'all' ) {
319 $this->
addWhere( $db->buildComparison( $op, [
320 'ar_namespace' => $cont[0],
321 'ar_title' => $cont[1],
322 'ar_timestamp' => $db->timestamp( $cont[2] ),
327 $this->
addWhere( $db->buildComparison( $op, [
328 'ar_timestamp' => $db->timestamp( $cont[0] ),
334 $this->
addOption(
'LIMIT', $this->limit + 1 );
336 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
338 if ( $optimizeGenerateTitles ) {
340 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
341 $orderby[] =
"ar_namespace $sort";
343 $orderby[] =
"ar_title $sort";
344 } elseif ( $mode ==
'all' ) {
346 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
347 $orderby[] =
"ar_namespace $sort";
349 $orderby[] =
"ar_title $sort";
350 $orderby[] =
"ar_timestamp $sort";
351 $orderby[] =
"ar_id $sort";
355 $orderby[] =
"ar_timestamp $sort";
356 $orderby[] =
"ar_id $sort";
358 $this->
addOption(
'ORDER BY', $orderby );
360 $res = $this->
select( __METHOD__ );
362 if ( $resultPageSet ===
null ) {
370 foreach ( $res as $row ) {
371 if ( ++$count > $this->limit ) {
373 if ( $optimizeGenerateTitles ) {
375 } elseif ( $mode ==
'all' ) {
377 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
386 if ( $miser_ns !==
null && !in_array( $row->ar_namespace, $miser_ns ) ) {
390 if ( $resultPageSet !==
null ) {
391 if ( $params[
'generatetitles'] ) {
392 $key =
"{$row->ar_namespace}:{$row->ar_title}";
393 if ( !isset( $generated[$key] ) ) {
394 $generated[$key] = Title::makeTitle( $row->ar_namespace, $row->ar_title );
397 $generated[] = $row->ar_rev_id;
400 $revision = $this->revisionStore->newRevisionFromArchiveRow( $row );
403 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
404 $index = $nextIndex++;
405 $pageMap[$row->ar_namespace][$row->ar_title] = $index;
406 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
408 'pageid' => $title->getArticleID(),
409 'revisions' => [ $rev ],
413 $fit = $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
415 $index = $pageMap[$row->ar_namespace][$row->ar_title];
416 $fit = $result->addValue(
421 if ( $mode ==
'all' ) {
423 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
433 if ( $resultPageSet !==
null ) {
434 if ( $params[
'generatetitles'] ) {
435 $resultPageSet->populateFromTitles( $generated );
437 $resultPageSet->populateFromRevisionIDs( $generated );
440 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
445 $ret = parent::getAllowedParams() + [
447 ParamValidator::PARAM_TYPE =>
'user',
448 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
451 ParamValidator::PARAM_ISMULTI =>
true,
452 ParamValidator::PARAM_TYPE =>
'namespace',
455 ParamValidator::PARAM_TYPE =>
'timestamp',
459 ParamValidator::PARAM_TYPE =>
'timestamp',
463 ParamValidator::PARAM_TYPE => [
467 ParamValidator::PARAM_DEFAULT =>
'older',
470 'newer' =>
'api-help-paramvalue-direction-newer',
471 'older' =>
'api-help-paramvalue-direction-older',
484 ParamValidator::PARAM_TYPE =>
'user',
485 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
492 'generatetitles' => [
493 ParamValidator::PARAM_DEFAULT => false
497 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
499 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
502 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
511 'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50'
512 =>
'apihelp-query+alldeletedrevisions-example-user',
513 'action=query&list=alldeletedrevisions&adrdir=newer&adrnamespace=0&adrlimit=50'
514 =>
'apihelp-query+alldeletedrevisions-example-ns-main',
519 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,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
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.
__construct(ApiQuery $query, $moduleName, RevisionStore $revisionStore, IContentHandlerFactory $contentHandlerFactory, ParserFactory $parserFactory, SlotRoleRegistry $slotRoleRegistry, NameTableStore $changeTagDefStore, NamespaceInfo $namespaceInfo, ContentRenderer $contentRenderer, ContentTransformer $contentTransformer, CommentFormatter $commentFormatter, TempUserCreator $tempUserCreator, UserFactory $userFactory)
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.
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.