38 parent::__construct( $query, $moduleName,
'drv' );
45 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
46 $pageCount = count( $pageSet->getGoodAndMissingTitles() );
47 $revCount = $pageSet->getRevisionCount();
48 if ( $revCount === 0 && $pageCount === 0 ) {
52 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
60 $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
64 if ( $resultPageSet ===
null ) {
66 $arQuery = $revisionStore->getArchiveQueryInfo();
70 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
74 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
77 if ( $this->fld_tags ) {
81 if ( !is_null( $params[
'tag'] ) ) {
84 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
86 $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
88 $this->
addWhereFld(
'ct_tag_id', $changeTagDefStore->getId( $params[
'tag'] ) );
96 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
99 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
101 if ( $this->fetchContent &&
104 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
107 $dir = $params[
'dir'];
109 if ( $revCount !== 0 ) {
111 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
115 $lb =
new LinkBatch( $pageSet->getGoodAndMissingTitles() );
116 $where = $lb->constructSet(
'ar', $db );
120 if ( !is_null( $params[
'user'] ) ) {
122 $actorQuery = ActorMigration::newMigration()
123 ->getWhere( $db,
'ar_user', User::newFromName( $params[
'user'],
false ),
false );
124 $this->
addTables( $actorQuery[
'tables'] );
126 $this->
addWhere( $actorQuery[
'conds'] );
127 } elseif ( !is_null( $params[
'excludeuser'] ) ) {
129 $actorQuery = ActorMigration::newMigration()
130 ->getWhere( $db,
'ar_user', User::newFromName( $params[
'excludeuser'],
false ) );
131 $this->
addTables( $actorQuery[
'tables'] );
133 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
136 if ( !is_null( $params[
'user'] ) || !is_null( $params[
'excludeuser'] ) ) {
139 $bitmask = RevisionRecord::DELETED_USER;
141 ->userHasAnyRight( $this->
getUser(),
'suppressrevision',
'viewsuppressed' )
143 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
148 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
152 if ( !is_null( $params[
'continue'] ) ) {
153 $cont = explode(
'|', $params[
'continue'] );
154 $op = ( $dir ==
'newer' ?
'>' :
'<' );
155 if ( $revCount !== 0 ) {
157 $rev = (int)$cont[0];
159 $ar_id = (int)$cont[1];
161 $this->
addWhere(
"ar_rev_id $op $rev OR " .
162 "(ar_rev_id = $rev AND " .
163 "ar_id $op= $ar_id)" );
168 $title = $db->addQuotes( $cont[1] );
169 $ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
170 $ar_id = (int)$cont[3];
172 $this->
addWhere(
"ar_namespace $op $ns OR " .
173 "(ar_namespace = $ns AND " .
174 "(ar_title $op $title OR " .
175 "(ar_title = $title AND " .
176 "(ar_timestamp $op $ts OR " .
177 "(ar_timestamp = $ts AND " .
178 "ar_id $op= $ar_id)))))" );
182 $this->
addOption(
'LIMIT', $this->limit + 1 );
184 if ( $revCount !== 0 ) {
190 if ( count( $pageMap ) > 1 ) {
193 $oneTitle = key( reset( $pageMap ) );
194 foreach ( $pageMap as $pages ) {
195 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
208 foreach (
$res as $row ) {
209 if ( ++$count > $this->limit ) {
213 ?
"$row->ar_rev_id|$row->ar_id"
214 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
219 if ( $resultPageSet !==
null ) {
220 $generated[] = $row->ar_rev_id;
222 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
224 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
225 $converted = $pageSet->getConvertedTitles();
226 if (
$title && isset( $converted[
$title->getPrefixedText()] ) ) {
227 $title = Title::newFromText( $converted[
$title->getPrefixedText()] );
229 $pageMap[$row->ar_namespace][$row->ar_title] =
234 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
237 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
242 $pageMap[$row->ar_namespace][$row->ar_title],
243 $this->extractRevisionInfo( $revisionStore->newRevisionFromArchiveRow( $row ), $row ),
249 ?
"$row->ar_rev_id|$row->ar_id"
250 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
257 if ( $resultPageSet !==
null ) {
258 $resultPageSet->populateFromRevisionIDs( $generated );
263 return parent::getAllowedParams() + [
293 'action=query&prop=deletedrevisions&titles=Main%20Page|Talk:Main%20Page&' .
294 'drvslots=*&drvprop=user|comment|content'
295 =>
'apihelp-query+deletedrevisions-example-titles',
296 'action=query&prop=deletedrevisions&revids=123456'
297 =>
'apihelp-query+deletedrevisions-example-revids',
302 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Deletedrevisions';
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
This class contains a list of pages that the client has requested.
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
addFields( $value)
Add a set of fields to select to the internal array.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
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)
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 ] )
addWhere( $value)
Add a set of WHERE clauses to the internal array.
Query module to enumerate deleted revisions for pages.
__construct(ApiQuery $query, $moduleName)
getExamplesMessages()
Returns usage examples for this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getHelpUrls()
Return links to more detailed help pages about the module.
run(ApiPageSet $resultPageSet=null)
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
getPageSet()
Get the PageSet object to work on.
A base class for functions common to producing a list of revisions.
parseParameters( $params)
Parse the parameters into the various instance fields.
This is the main query class.
Class representing a list of titles The execute() method checks them all for existence and adds them ...