97 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
98 $pageCount = count( $pageSet->getGoodAndMissingPages() );
99 $revCount = $pageSet->getRevisionCount();
100 if ( $revCount === 0 && $pageCount === 0 ) {
104 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
111 $db = $this->
getDB();
115 if ( $resultPageSet ===
null ) {
117 $arQuery = $this->revisionStore->getArchiveQueryInfo();
121 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
125 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
128 if ( $this->fld_tags ) {
132 if ( $params[
'tag'] !==
null ) {
135 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
138 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
146 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
149 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
151 if ( $this->fetchContent && !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' ) ) {
152 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
155 $dir = $params[
'dir'];
157 if ( $revCount !== 0 ) {
159 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
163 $lb = $this->linkBatchFactory->newLinkBatch( $pageSet->getGoodAndMissingPages() );
164 $where = $lb->constructSet(
'ar', $db );
168 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
170 if ( $resultPageSet !==
null ) {
172 $this->
addJoinConds( [
'actor' => [
'JOIN',
'actor_id=ar_actor' ] ] );
174 if ( $params[
'user'] !==
null ) {
175 $this->
addWhereFld(
'actor_name', $params[
'user'] );
176 } elseif ( $params[
'excludeuser'] !==
null ) {
177 $this->
addWhere(
'actor_name<>' . $db->addQuotes( $params[
'excludeuser'] ) );
181 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
183 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
184 $bitmask = RevisionRecord::DELETED_USER;
185 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
186 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
191 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
195 if ( $params[
'continue'] !==
null ) {
196 $cont = explode(
'|', $params[
'continue'] );
197 $op = ( $dir ==
'newer' ?
'>' :
'<' );
198 if ( $revCount !== 0 ) {
200 $rev = (int)$cont[0];
202 $ar_id = (int)$cont[1];
204 $this->
addWhere(
"ar_rev_id $op $rev OR " .
205 "(ar_rev_id = $rev AND " .
206 "ar_id $op= $ar_id)" );
211 $title = $db->addQuotes( $cont[1] );
212 $ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
213 $ar_id = (int)$cont[3];
215 $this->
addWhere(
"ar_namespace $op $ns OR " .
216 "(ar_namespace = $ns AND " .
217 "(ar_title $op $title OR " .
218 "(ar_title = $title AND " .
219 "(ar_timestamp $op $ts OR " .
220 "(ar_timestamp = $ts AND " .
221 "ar_id $op= $ar_id)))))" );
225 $this->
addOption(
'LIMIT', $this->limit + 1 );
227 if ( $revCount !== 0 ) {
233 if ( count( $pageMap ) > 1 ) {
236 $oneTitle = key( reset( $pageMap ) );
237 foreach ( $pageMap as $pages ) {
238 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
251 foreach (
$res as $row ) {
252 if ( ++$count > $this->limit ) {
256 ?
"$row->ar_rev_id|$row->ar_id"
257 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
262 if ( $resultPageSet !==
null ) {
263 $generated[] = $row->ar_rev_id;
265 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
268 $converted = $pageSet->getConvertedTitles();
269 if (
$title && isset( $converted[
$title->getPrefixedText()] ) ) {
272 $pageMap[$row->ar_namespace][$row->ar_title] =
277 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
280 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
285 $pageMap[$row->ar_namespace][$row->ar_title],
286 $this->extractRevisionInfo( $this->revisionStore->newRevisionFromArchiveRow( $row ), $row ),
292 ?
"$row->ar_rev_id|$row->ar_id"
293 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
300 if ( $resultPageSet !==
null ) {
301 $resultPageSet->populateFromRevisionIDs( $generated );
306 return parent::getAllowedParams() + [
324 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
328 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
338 'action=query&prop=deletedrevisions&titles=Main%20Page|Talk:Main%20Page&' .
339 'drvslots=*&drvprop=user|comment|content'
340 =>
'apihelp-query+deletedrevisions-example-titles',
341 'action=query&prop=deletedrevisions&revids=123456'
342 =>
'apihelp-query+deletedrevisions-example-revids',
347 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.
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)
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, RevisionStore $revisionStore, IContentHandlerFactory $contentHandlerFactory, ParserFactory $parserFactory, SlotRoleRegistry $slotRoleRegistry, NameTableStore $changeTagDefStore, LinkBatchFactory $linkBatchFactory, ContentRenderer $contentRenderer, ContentTransformer $contentTransformer)
LinkBatchFactory $linkBatchFactory
getExamplesMessages()
Returns usage examples for this module.
NameTableStore $changeTagDefStore
RevisionStore $revisionStore
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.
ContentRenderer $contentRenderer
parseParameters( $params)
Parse the parameters into the various instance fields.
IContentHandlerFactory $contentHandlerFactory
ContentTransformer $contentTransformer
SlotRoleRegistry $slotRoleRegistry
ParserFactory $parserFactory
This is the main query class.
A service to render content.
A service to transform content.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.