Go to the documentation of this file.
38 parent::__construct( $query, $moduleName,
'adr' );
49 $services = MediaWikiServices::getInstance();
50 $revisionStore = $services->getRevisionStore();
55 if ( $params[
'namespace'] === [] ) {
56 if ( $resultPageSet ===
null ) {
66 if ( !is_null( $params[
'user'] ) ) {
70 if ( $mode ==
'user' ) {
71 foreach ( [
'from',
'to',
'prefix',
'excludeuser' ] as $param ) {
72 if ( !is_null( $params[$param] ) ) {
75 [
'apierror-invalidparammix-cannotusewith', $p . $param,
"{$p}user" ],
81 foreach ( [
'start',
'end' ] as $param ) {
82 if ( !is_null( $params[$param] ) ) {
85 [
'apierror-invalidparammix-mustusewith', $p . $param,
"{$p}user" ],
96 $dir = $params[
'dir'];
97 $optimizeGenerateTitles =
false;
98 if ( $mode ===
'all' && $params[
'generatetitles'] && $resultPageSet !==
null ) {
99 if ( $dir ===
'newer' ) {
100 $optimizeGenerateTitles =
true;
103 $this->
addWarning( [
'apiwarn-alldeletedrevisions-performance', $p ],
'performance' );
107 if ( $resultPageSet ===
null ) {
109 $arQuery = $revisionStore->getArchiveQueryInfo();
113 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
117 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
118 if ( $optimizeGenerateTitles ) {
121 $this->
addFields( [
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
125 if ( $this->fld_tags ) {
129 if ( !is_null( $params[
'tag'] ) ) {
132 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
134 $changeTagDefStore = $services->getChangeTagDefStore();
136 $this->
addWhereFld(
'ct_tag_id', $changeTagDefStore->getId( $params[
'tag'] ) );
144 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
147 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
149 if ( $this->fetchContent &&
152 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
157 if ( $mode ==
'all' ) {
158 $namespaces = $params[
'namespace'] ??
159 $services->getNamespaceInfo()->getValidNamespaces();
166 if ( $params[
'from'] !==
null || $params[
'to'] !==
null ) {
167 $isDirNewer = ( $dir ===
'newer' );
168 $after = ( $isDirNewer ?
'>=' :
'<=' );
169 $before = ( $isDirNewer ?
'<=' :
'>=' );
171 foreach ( $namespaces as $ns ) {
173 if ( $params[
'from'] !==
null ) {
174 $w[] =
'ar_title' . $after .
177 if ( $params[
'to'] !==
null ) {
178 $w[] =
'ar_title' . $before .
184 if ( count(
$where ) == 1 ) {
189 foreach (
$where as $w => $ns ) {
190 $where2[] = $db->makeList( [ $w,
'ar_namespace' => $ns ],
LIST_AND );
196 if ( isset( $params[
'prefix'] ) ) {
198 foreach ( $namespaces as $ns ) {
199 $w =
'ar_title' . $db->buildLike(
204 if ( count(
$where ) == 1 ) {
209 foreach (
$where as $w => $ns ) {
210 $where2[] = $db->makeList( [ $w,
'ar_namespace' => $ns ],
LIST_AND );
216 if ( $this->
getConfig()->get(
'MiserMode' ) ) {
217 $miser_ns = $params[
'namespace'];
219 $this->
addWhereFld(
'ar_namespace', $params[
'namespace'] );
224 if ( !is_null( $params[
'user'] ) ) {
227 ->getWhere( $db,
'ar_user',
User::newFromName( $params[
'user'],
false ),
false );
228 $this->
addTables( $actorQuery[
'tables'] );
230 $this->
addWhere( $actorQuery[
'conds'] );
231 } elseif ( !is_null( $params[
'excludeuser'] ) ) {
234 ->getWhere( $db,
'ar_user',
User::newFromName( $params[
'excludeuser'],
false ) );
235 $this->
addTables( $actorQuery[
'tables'] );
237 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
240 if ( !is_null( $params[
'user'] ) || !is_null( $params[
'excludeuser'] ) ) {
243 $bitmask = RevisionRecord::DELETED_USER;
245 ->userHasAnyRight( $user,
'suppressrevision',
'viewsuppressed' )
247 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
252 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
256 if ( !is_null( $params[
'continue'] ) ) {
257 $cont = explode(
'|', $params[
'continue'] );
258 $op = ( $dir ==
'newer' ?
'>' :
'<' );
259 if ( $optimizeGenerateTitles ) {
263 $title = $db->addQuotes( $cont[1] );
264 $this->
addWhere(
"ar_namespace $op $ns OR " .
265 "(ar_namespace = $ns AND ar_title $op= $title)" );
266 } elseif ( $mode ==
'all' ) {
270 $title = $db->addQuotes( $cont[1] );
271 $ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
272 $ar_id = (int)$cont[3];
274 $this->
addWhere(
"ar_namespace $op $ns OR " .
275 "(ar_namespace = $ns AND " .
276 "(ar_title $op $title OR " .
277 "(ar_title = $title AND " .
278 "(ar_timestamp $op $ts OR " .
279 "(ar_timestamp = $ts AND " .
280 "ar_id $op= $ar_id)))))" );
283 $ts = $db->addQuotes( $db->timestamp( $cont[0] ) );
284 $ar_id = (int)$cont[1];
286 $this->
addWhere(
"ar_timestamp $op $ts OR " .
287 "(ar_timestamp = $ts AND " .
288 "ar_id $op= $ar_id)" );
292 $this->
addOption(
'LIMIT', $this->limit + 1 );
294 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
296 if ( $optimizeGenerateTitles ) {
298 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
299 $orderby[] =
"ar_namespace $sort";
301 $orderby[] =
"ar_title $sort";
302 } elseif ( $mode ==
'all' ) {
304 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
305 $orderby[] =
"ar_namespace $sort";
307 $orderby[] =
"ar_title $sort";
308 $orderby[] =
"ar_timestamp $sort";
309 $orderby[] =
"ar_id $sort";
313 $orderby[] =
"ar_timestamp $sort";
314 $orderby[] =
"ar_id $sort";
316 $this->
addOption(
'ORDER BY', $orderby );
323 foreach (
$res as $row ) {
324 if ( ++$count > $this->limit ) {
326 if ( $optimizeGenerateTitles ) {
328 } elseif ( $mode ==
'all' ) {
330 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
339 if ( $miser_ns !==
null && !in_array( $row->ar_namespace, $miser_ns ) ) {
343 if ( $resultPageSet !==
null ) {
344 if ( $params[
'generatetitles'] ) {
345 $key =
"{$row->ar_namespace}:{$row->ar_title}";
346 if ( !isset( $generated[$key] ) ) {
350 $generated[] = $row->ar_rev_id;
353 $revision = $revisionStore->newRevisionFromArchiveRow( $row );
356 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
357 $index = $nextIndex++;
358 $pageMap[$row->ar_namespace][$row->ar_title] = $index;
361 'pageid' =>
$title->getArticleID(),
362 'revisions' => [ $rev ],
366 $fit = $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
368 $index = $pageMap[$row->ar_namespace][$row->ar_title];
369 $fit = $result->addValue(
374 if ( $mode ==
'all' ) {
376 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
386 if ( $resultPageSet !==
null ) {
387 if ( $params[
'generatetitles'] ) {
388 $resultPageSet->populateFromTitles( $generated );
390 $resultPageSet->populateFromRevisionIDs( $generated );
393 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
398 $ret = parent::getAllowedParams() + [
439 'generatetitles' => [
444 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
446 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
449 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
458 'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50'
459 =>
'apihelp-query+alldeletedrevisions-example-user',
460 'action=query&list=alldeletedrevisions&adrdir=newer&adrnamespace=0&adrlimit=50'
461 =>
'apihelp-query+alldeletedrevisions-example-ns-main',
466 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Alldeletedrevisions';
parseParameters( $params)
Parse the parameters into the various instance fields.
addFields( $value)
Add a set of fields to select to the internal array.
This is the main query class.
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
static newMigration()
Static constructor.
This class contains a list of pages that the client has requested.
A base class for functions common to producing a list of revisions.
getHelpUrls()
Return links to more detailed help pages about the module.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
getDB()
Get the Query database connection (read-only)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
getExamplesMessages()
Returns usage examples for this module.
run(ApiPageSet $resultPageSet=null)
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
extractRevisionInfo(RevisionRecord $revision, $row)
Extract information from the RevisionRecord.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
__construct(ApiQuery $query, $moduleName)
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
titlePartToKey( $titlePart, $namespace=NS_MAIN)
Convert an input title or title prefix into a dbkey.
Query module to enumerate all deleted revisions.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.