93 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
94 $pageCount = count( $pageSet->getGoodAndMissingPages() );
95 $revCount = $pageSet->getRevisionCount();
96 if ( $revCount === 0 && $pageCount === 0 ) {
100 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
107 $db = $this->
getDB();
111 if ( $resultPageSet ===
null ) {
113 $arQuery = $this->revisionStore->getArchiveQueryInfo();
117 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
121 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
124 if ( $this->fld_tags ) {
128 if ( $params[
'tag'] !==
null ) {
131 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
134 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
142 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
145 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
147 if ( $this->fetchContent && !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' ) ) {
148 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
151 $dir = $params[
'dir'];
153 if ( $revCount !== 0 ) {
155 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
159 $lb = $this->linkBatchFactory->newLinkBatch( $pageSet->getGoodAndMissingPages() );
160 $where = $lb->constructSet(
'ar', $db );
164 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
166 if ( $resultPageSet !==
null ) {
168 $this->
addJoinConds( [
'actor' => [
'JOIN',
'actor_id=ar_actor' ] ] );
170 if ( $params[
'user'] !==
null ) {
171 $this->
addWhereFld(
'actor_name', $params[
'user'] );
172 } elseif ( $params[
'excludeuser'] !==
null ) {
173 $this->
addWhere(
'actor_name<>' . $db->addQuotes( $params[
'excludeuser'] ) );
177 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
179 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
180 $bitmask = RevisionRecord::DELETED_USER;
181 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
182 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
187 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
191 if ( $params[
'continue'] !==
null ) {
192 $cont = explode(
'|', $params[
'continue'] );
193 $op = ( $dir ==
'newer' ?
'>' :
'<' );
194 if ( $revCount !== 0 ) {
196 $rev = (int)$cont[0];
198 $ar_id = (int)$cont[1];
200 $this->
addWhere(
"ar_rev_id $op $rev OR " .
201 "(ar_rev_id = $rev AND " .
202 "ar_id $op= $ar_id)" );
207 $title = $db->addQuotes( $cont[1] );
208 $ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
209 $ar_id = (int)$cont[3];
211 $this->
addWhere(
"ar_namespace $op $ns OR " .
212 "(ar_namespace = $ns AND " .
213 "(ar_title $op $title OR " .
214 "(ar_title = $title AND " .
215 "(ar_timestamp $op $ts OR " .
216 "(ar_timestamp = $ts AND " .
217 "ar_id $op= $ar_id)))))" );
221 $this->
addOption(
'LIMIT', $this->limit + 1 );
223 if ( $revCount !== 0 ) {
229 if ( count( $pageMap ) > 1 ) {
232 $oneTitle = key( reset( $pageMap ) );
233 foreach ( $pageMap as $pages ) {
234 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
247 foreach (
$res as $row ) {
248 if ( ++$count > $this->limit ) {
252 ?
"$row->ar_rev_id|$row->ar_id"
253 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
258 if ( $resultPageSet !==
null ) {
259 $generated[] = $row->ar_rev_id;
261 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
263 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
264 $converted = $pageSet->getConvertedTitles();
265 if (
$title && isset( $converted[
$title->getPrefixedText()] ) ) {
266 $title = Title::newFromText( $converted[
$title->getPrefixedText()] );
268 $pageMap[$row->ar_namespace][$row->ar_title] =
273 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
276 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
281 $pageMap[$row->ar_namespace][$row->ar_title],
282 $this->extractRevisionInfo( $this->revisionStore->newRevisionFromArchiveRow( $row ), $row ),
288 ?
"$row->ar_rev_id|$row->ar_id"
289 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
296 if ( $resultPageSet !==
null ) {
297 $resultPageSet->populateFromRevisionIDs( $generated );
302 return parent::getAllowedParams() + [
320 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
324 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
334 'action=query&prop=deletedrevisions&titles=Main%20Page|Talk:Main%20Page&' .
335 'drvslots=*&drvprop=user|comment|content'
336 =>
'apihelp-query+deletedrevisions-example-titles',
337 'action=query&prop=deletedrevisions&revids=123456'
338 =>
'apihelp-query+deletedrevisions-example-revids',
343 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.
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, 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.
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 transform content.