Go to the documentation of this file.
43 parent::__construct( $query, $moduleName,
'drv' );
50 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
51 $pageCount = count( $pageSet->getGoodAndMissingTitles() );
52 $revCount = $pageSet->getRevisionCount();
53 if ( $revCount === 0 && $pageCount === 0 ) {
57 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
65 $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
69 if ( $resultPageSet ===
null ) {
71 $arQuery = $revisionStore->getArchiveQueryInfo();
75 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
79 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
82 if ( $this->fld_tags ) {
86 if ( $params[
'tag'] !==
null ) {
89 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
91 $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
93 $this->
addWhereFld(
'ct_tag_id', $changeTagDefStore->getId( $params[
'tag'] ) );
101 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
104 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
106 if ( $this->fetchContent &&
109 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
112 $dir = $params[
'dir'];
114 if ( $revCount !== 0 ) {
116 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
120 $linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
121 $lb = $linkBatchFactory->newLinkBatch( $pageSet->getGoodAndMissingTitles() );
122 $where = $lb->constructSet(
'ar', $db );
126 if ( $params[
'user'] !==
null ) {
129 ->getWhere( $db,
'ar_user', $params[
'user'],
false );
130 $this->
addTables( $actorQuery[
'tables'] );
132 $this->
addWhere( $actorQuery[
'conds'] );
133 } elseif ( $params[
'excludeuser'] !==
null ) {
136 ->getWhere( $db,
'ar_user', $params[
'excludeuser'] );
137 $this->
addTables( $actorQuery[
'tables'] );
139 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
142 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
145 $bitmask = RevisionRecord::DELETED_USER;
147 ->userHasAnyRight( $this->
getUser(),
'suppressrevision',
'viewsuppressed' )
149 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
154 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
158 if ( $params[
'continue'] !==
null ) {
159 $cont = explode(
'|', $params[
'continue'] );
160 $op = ( $dir ==
'newer' ?
'>' :
'<' );
161 if ( $revCount !== 0 ) {
163 $rev = (int)$cont[0];
165 $ar_id = (int)$cont[1];
167 $this->
addWhere(
"ar_rev_id $op $rev OR " .
168 "(ar_rev_id = $rev AND " .
169 "ar_id $op= $ar_id)" );
174 $title = $db->addQuotes( $cont[1] );
175 $ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
176 $ar_id = (int)$cont[3];
178 $this->
addWhere(
"ar_namespace $op $ns OR " .
179 "(ar_namespace = $ns AND " .
180 "(ar_title $op $title OR " .
181 "(ar_title = $title AND " .
182 "(ar_timestamp $op $ts OR " .
183 "(ar_timestamp = $ts AND " .
184 "ar_id $op= $ar_id)))))" );
188 $this->
addOption(
'LIMIT', $this->limit + 1 );
190 if ( $revCount !== 0 ) {
196 if ( count( $pageMap ) > 1 ) {
199 $oneTitle = key( reset( $pageMap ) );
200 foreach ( $pageMap as $pages ) {
201 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
214 foreach (
$res as $row ) {
215 if ( ++$count > $this->limit ) {
219 ?
"$row->ar_rev_id|$row->ar_id"
220 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
225 if ( $resultPageSet !==
null ) {
226 $generated[] = $row->ar_rev_id;
228 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
231 $converted = $pageSet->getConvertedTitles();
232 if (
$title && isset( $converted[
$title->getPrefixedText()] ) ) {
235 $pageMap[$row->ar_namespace][$row->ar_title] =
240 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
243 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
248 $pageMap[$row->ar_namespace][$row->ar_title],
249 $this->extractRevisionInfo( $revisionStore->newRevisionFromArchiveRow( $row ), $row ),
255 ?
"$row->ar_rev_id|$row->ar_id"
256 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
263 if ( $resultPageSet !==
null ) {
264 $resultPageSet->populateFromRevisionIDs( $generated );
269 return parent::getAllowedParams() + [
287 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
288 UserDef::PARAM_RETURN_OBJECT =>
true,
292 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
293 UserDef::PARAM_RETURN_OBJECT =>
true,
303 'action=query&prop=deletedrevisions&titles=Main%20Page|Talk:Main%20Page&' .
304 'drvslots=*&drvprop=user|comment|content'
305 =>
'apihelp-query+deletedrevisions-example-titles',
306 'action=query&prop=deletedrevisions&revids=123456'
307 =>
'apihelp-query+deletedrevisions-example-revids',
312 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Deletedrevisions';
run(ApiPageSet $resultPageSet=null)
parseParameters( $params)
Parse the parameters into the various instance fields.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
addFields( $value)
Add a set of fields to select to the internal array.
This is the main query class.
Query module to enumerate deleted revisions for pages.
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.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
getUser()
Stable to override.
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.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
getExamplesMessages()
Returns usage examples for this module.
getPageSet()
Get the PageSet object to work on.
getDB()
Get the Query database connection (read-only) Stable to override.
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,...
getHelpUrls()
Return links to more detailed help pages about the module.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
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.
requireMaxOneParameter( $params,... $required)
Die if more than one of a certain set of parameters is set and not false.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
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 ] )
getAllowedParams()
Stable to override.
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
__construct(ApiQuery $query, $moduleName)
addWhere( $value)
Add a set of WHERE clauses to the internal array.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.