100 if ( $params[
'namespace'] === [] ) {
101 if ( $resultPageSet ===
null ) {
111 if ( $params[
'user'] !==
null ) {
115 if ( $mode ==
'user' ) {
116 foreach ( [
'from',
'to',
'prefix',
'excludeuser' ] as $param ) {
117 if ( $params[$param] !==
null ) {
120 [
'apierror-invalidparammix-cannotusewith', $p . $param,
"{$p}user" ],
126 foreach ( [
'start',
'end' ] as $param ) {
127 if ( $params[$param] !==
null ) {
130 [
'apierror-invalidparammix-mustusewith', $p . $param,
"{$p}user" ],
141 $dir = $params[
'dir'];
142 $optimizeGenerateTitles =
false;
143 if ( $mode ===
'all' && $params[
'generatetitles'] && $resultPageSet !==
null ) {
144 if ( $dir ===
'newer' ) {
145 $optimizeGenerateTitles =
true;
148 $this->
addWarning( [
'apiwarn-alldeletedrevisions-performance', $p ],
'performance' );
152 if ( $resultPageSet ===
null ) {
154 $arQuery = $this->revisionStore->getArchiveQueryInfo();
158 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
162 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
163 if ( $optimizeGenerateTitles ) {
166 $this->
addFields( [
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
168 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
170 $this->
addJoinConds( [
'actor' =>
'actor_id=ar_actor' ] );
174 if ( $this->fld_tags ) {
178 if ( $params[
'tag'] !==
null ) {
181 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
184 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
192 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
195 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
197 if ( $this->fetchContent &&
198 !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' )
200 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
205 if ( $mode ==
'all' ) {
206 $namespaces = $params[
'namespace'] ?? $this->namespaceInfo->getValidNamespaces();
213 if ( $params[
'from'] !==
null || $params[
'to'] !==
null ) {
214 $isDirNewer = ( $dir ===
'newer' );
215 $after = ( $isDirNewer ?
'>=' :
'<=' );
216 $before = ( $isDirNewer ?
'<=' :
'>=' );
218 foreach ( $namespaces as $ns ) {
220 if ( $params[
'from'] !==
null ) {
221 $w[] =
'ar_title' . $after .
224 if ( $params[
'to'] !==
null ) {
225 $w[] =
'ar_title' . $before .
231 if ( count( $where ) == 1 ) {
232 $where = key( $where );
236 foreach ( $where as $w => $ns ) {
237 $where2[] = $db->makeList( [ $w,
'ar_namespace' => $ns ],
LIST_AND );
243 if ( isset( $params[
'prefix'] ) ) {
245 foreach ( $namespaces as $ns ) {
246 $w =
'ar_title' . $db->buildLike(
251 if ( count( $where ) == 1 ) {
252 $where = key( $where );
256 foreach ( $where as $w => $ns ) {
257 $where2[] = $db->makeList( [ $w,
'ar_namespace' => $ns ],
LIST_AND );
263 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
264 $miser_ns = $params[
'namespace'];
266 $this->
addWhereFld(
'ar_namespace', $params[
'namespace'] );
271 if ( $params[
'user'] !==
null ) {
276 $this->
addWhereFld(
'actor_name', $params[
'user'] );
277 } elseif ( $params[
'excludeuser'] !==
null ) {
278 $this->
addWhere(
'actor_name<>' . $db->addQuotes( $params[
'excludeuser'] ) );
281 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
283 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
284 $bitmask = RevisionRecord::DELETED_USER;
285 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
286 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
291 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
295 if ( $params[
'continue'] !==
null ) {
296 $cont = explode(
'|', $params[
'continue'] );
297 $op = ( $dir ==
'newer' ?
'>' :
'<' );
298 if ( $optimizeGenerateTitles ) {
302 $title = $db->addQuotes( $cont[1] );
303 $this->
addWhere(
"ar_namespace $op $ns OR " .
304 "(ar_namespace = $ns AND ar_title $op= $title)" );
305 } elseif ( $mode ==
'all' ) {
309 $title = $db->addQuotes( $cont[1] );
310 $ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
311 $ar_id = (int)$cont[3];
313 $this->
addWhere(
"ar_namespace $op $ns OR " .
314 "(ar_namespace = $ns AND " .
315 "(ar_title $op $title OR " .
316 "(ar_title = $title AND " .
317 "(ar_timestamp $op $ts OR " .
318 "(ar_timestamp = $ts AND " .
319 "ar_id $op= $ar_id)))))" );
322 $ts = $db->addQuotes( $db->timestamp( $cont[0] ) );
323 $ar_id = (int)$cont[1];
325 $this->
addWhere(
"ar_timestamp $op $ts OR " .
326 "(ar_timestamp = $ts AND " .
327 "ar_id $op= $ar_id)" );
331 $this->
addOption(
'LIMIT', $this->limit + 1 );
333 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
335 if ( $optimizeGenerateTitles ) {
337 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
338 $orderby[] =
"ar_namespace $sort";
340 $orderby[] =
"ar_title $sort";
341 } elseif ( $mode ==
'all' ) {
343 if ( $params[
'namespace'] ===
null || count( array_unique( $params[
'namespace'] ) ) > 1 ) {
344 $orderby[] =
"ar_namespace $sort";
346 $orderby[] =
"ar_title $sort";
347 $orderby[] =
"ar_timestamp $sort";
348 $orderby[] =
"ar_id $sort";
352 $orderby[] =
"ar_timestamp $sort";
353 $orderby[] =
"ar_id $sort";
355 $this->
addOption(
'ORDER BY', $orderby );
359 if ( $resultPageSet ===
null ) {
367 foreach (
$res as $row ) {
368 if ( ++$count > $this->limit ) {
370 if ( $optimizeGenerateTitles ) {
372 } elseif ( $mode ==
'all' ) {
374 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
383 if ( $miser_ns !==
null && !in_array( $row->ar_namespace, $miser_ns ) ) {
387 if ( $resultPageSet !==
null ) {
388 if ( $params[
'generatetitles'] ) {
389 $key =
"{$row->ar_namespace}:{$row->ar_title}";
390 if ( !isset( $generated[$key] ) ) {
391 $generated[$key] = Title::makeTitle( $row->ar_namespace, $row->ar_title );
394 $generated[] = $row->ar_rev_id;
397 $revision = $this->revisionStore->newRevisionFromArchiveRow( $row );
400 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
401 $index = $nextIndex++;
402 $pageMap[$row->ar_namespace][$row->ar_title] = $index;
403 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
405 'pageid' =>
$title->getArticleID(),
406 'revisions' => [ $rev ],
408 ApiResult::setIndexedTagName( $a[
'revisions'],
'rev' );
410 $fit = $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
412 $index = $pageMap[$row->ar_namespace][$row->ar_title];
413 $fit = $result->addValue(
418 if ( $mode ==
'all' ) {
420 "$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
430 if ( $resultPageSet !==
null ) {
431 if ( $params[
'generatetitles'] ) {
432 $resultPageSet->populateFromTitles( $generated );
434 $resultPageSet->populateFromRevisionIDs( $generated );
437 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
442 $ret = parent::getAllowedParams() + [
445 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
478 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
485 'generatetitles' => [
490 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
492 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
495 'apihelp-query+alldeletedrevisions-param-miser-user-namespace',
504 'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50'
505 =>
'apihelp-query+alldeletedrevisions-example-user',
506 'action=query&list=alldeletedrevisions&adrdir=newer&adrnamespace=0&adrlimit=50'
507 =>
'apihelp-query+alldeletedrevisions-example-ns-main',
512 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 ...
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.
NamespaceInfo $namespaceInfo
RevisionStore $revisionStore
getExamplesMessages()
Returns usage examples for this module.
getHelpUrls()
Return links to more detailed help pages about the module.
NameTableStore $changeTagDefStore
run(ApiPageSet $resultPageSet=null)
__construct(ApiQuery $query, $moduleName, RevisionStore $revisionStore, IContentHandlerFactory $contentHandlerFactory, ParserFactory $parserFactory, SlotRoleRegistry $slotRoleRegistry, NameTableStore $changeTagDefStore, NamespaceInfo $namespaceInfo, ContentTransformer $contentTransformer)
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.
IContentHandlerFactory $contentHandlerFactory
ContentTransformer $contentTransformer
SlotRoleRegistry $slotRoleRegistry
ParserFactory $parserFactory
extractRevisionInfo(RevisionRecord $revision, $row)
Extract information from the RevisionRecord.
This is the main query class.
A service to transform content.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...