39 parent::__construct( $query, $moduleName,
'drv' );
46 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
47 $pageCount = count( $pageSet->getGoodAndMissingTitles() );
48 $revCount = $pageSet->getRevisionCount();
49 if ( $revCount === 0 && $pageCount === 0 ) {
53 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
61 $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
65 if ( $resultPageSet ===
null ) {
67 $arQuery = $revisionStore->getArchiveQueryInfo();
71 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
75 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
78 if ( $this->fld_tags ) {
82 if ( $params[
'tag'] !==
null ) {
85 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
87 $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
89 $this->
addWhereFld(
'ct_tag_id', $changeTagDefStore->getId( $params[
'tag'] ) );
97 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
100 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
102 if ( $this->fetchContent &&
105 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
108 $dir = $params[
'dir'];
110 if ( $revCount !== 0 ) {
112 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
116 $lb =
new LinkBatch( $pageSet->getGoodAndMissingTitles() );
117 $where = $lb->constructSet(
'ar', $db );
121 if ( $params[
'user'] !==
null ) {
123 $actorQuery = ActorMigration::newMigration()
124 ->getWhere( $db,
'ar_user', $params[
'user'],
false );
125 $this->
addTables( $actorQuery[
'tables'] );
127 $this->
addWhere( $actorQuery[
'conds'] );
128 } elseif ( $params[
'excludeuser'] !==
null ) {
130 $actorQuery = ActorMigration::newMigration()
131 ->getWhere( $db,
'ar_user', $params[
'excludeuser'] );
132 $this->
addTables( $actorQuery[
'tables'] );
134 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
137 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
140 $bitmask = RevisionRecord::DELETED_USER;
142 ->userHasAnyRight( $this->
getUser(),
'suppressrevision',
'viewsuppressed' )
144 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
149 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
153 if ( $params[
'continue'] !==
null ) {
154 $cont = explode(
'|', $params[
'continue'] );
155 $op = ( $dir ==
'newer' ?
'>' :
'<' );
156 if ( $revCount !== 0 ) {
158 $rev = (int)$cont[0];
160 $ar_id = (int)$cont[1];
162 $this->
addWhere(
"ar_rev_id $op $rev OR " .
163 "(ar_rev_id = $rev AND " .
164 "ar_id $op= $ar_id)" );
169 $title = $db->addQuotes( $cont[1] );
170 $ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
171 $ar_id = (int)$cont[3];
173 $this->
addWhere(
"ar_namespace $op $ns OR " .
174 "(ar_namespace = $ns AND " .
175 "(ar_title $op $title OR " .
176 "(ar_title = $title AND " .
177 "(ar_timestamp $op $ts OR " .
178 "(ar_timestamp = $ts AND " .
179 "ar_id $op= $ar_id)))))" );
183 $this->
addOption(
'LIMIT', $this->limit + 1 );
185 if ( $revCount !== 0 ) {
191 if ( count( $pageMap ) > 1 ) {
194 $oneTitle = key( reset( $pageMap ) );
195 foreach ( $pageMap as $pages ) {
196 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
209 foreach (
$res as $row ) {
210 if ( ++$count > $this->limit ) {
214 ?
"$row->ar_rev_id|$row->ar_id"
215 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
220 if ( $resultPageSet !==
null ) {
221 $generated[] = $row->ar_rev_id;
223 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
225 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
226 $converted = $pageSet->getConvertedTitles();
227 if (
$title && isset( $converted[
$title->getPrefixedText()] ) ) {
228 $title = Title::newFromText( $converted[
$title->getPrefixedText()] );
230 $pageMap[$row->ar_namespace][$row->ar_title] =
235 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
238 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
243 $pageMap[$row->ar_namespace][$row->ar_title],
244 $this->extractRevisionInfo( $revisionStore->newRevisionFromArchiveRow( $row ), $row ),
250 ?
"$row->ar_rev_id|$row->ar_id"
251 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
258 if ( $resultPageSet !==
null ) {
259 $resultPageSet->populateFromRevisionIDs( $generated );
264 return parent::getAllowedParams() + [
282 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
283 UserDef::PARAM_RETURN_OBJECT =>
true,
287 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
288 UserDef::PARAM_RETURN_OBJECT =>
true,
298 'action=query&prop=deletedrevisions&titles=Main%20Page|Talk:Main%20Page&' .
299 'drvslots=*&drvprop=user|comment|content'
300 =>
'apihelp-query+deletedrevisions-example-titles',
301 'action=query&prop=deletedrevisions&revids=123456'
302 =>
'apihelp-query+deletedrevisions-example-revids',
307 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Deletedrevisions';
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
requireMaxOneParameter( $params,... $required)
Die if more than one of a certain set of parameters is set and not false.
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.
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) Stable to override.
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()
Stable to override.
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 ...