46 private $revisionStore;
49 private $changeTagDefStore;
52 private $linkBatchFactory;
83 $contentHandlerFactory,
89 $this->revisionStore = $revisionStore;
90 $this->changeTagDefStore = $changeTagDefStore;
91 $this->linkBatchFactory = $linkBatchFactory;
96 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
97 $pageCount = count( $pageSet->getGoodAndMissingPages() );
98 $revCount = $pageSet->getRevisionCount();
99 if ( $revCount === 0 && $pageCount === 0 ) {
103 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
110 $db = $this->
getDB();
114 if ( $resultPageSet ===
null ) {
116 $arQuery = $this->revisionStore->getArchiveQueryInfo();
120 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
124 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
127 if ( $this->fld_tags ) {
131 if ( $params[
'tag'] !==
null ) {
134 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
137 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
145 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
148 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
150 if ( $this->fetchContent && !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' ) ) {
151 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
154 $dir = $params[
'dir'];
156 if ( $revCount !== 0 ) {
158 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
162 $lb = $this->linkBatchFactory->newLinkBatch( $pageSet->getGoodAndMissingPages() );
163 $where = $lb->constructSet(
'ar', $db );
167 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
169 if ( $resultPageSet !==
null ) {
171 $this->
addJoinConds( [
'actor' => [
'JOIN',
'actor_id=ar_actor' ] ] );
173 if ( $params[
'user'] !==
null ) {
174 $this->
addWhereFld(
'actor_name', $params[
'user'] );
175 } elseif ( $params[
'excludeuser'] !==
null ) {
176 $this->
addWhere(
'actor_name<>' . $db->addQuotes( $params[
'excludeuser'] ) );
180 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
182 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
183 $bitmask = RevisionRecord::DELETED_USER;
184 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
185 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
190 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
194 if ( $params[
'continue'] !==
null ) {
195 $cont = explode(
'|', $params[
'continue'] );
196 $op = ( $dir ==
'newer' ?
'>' :
'<' );
197 if ( $revCount !== 0 ) {
199 $rev = (int)$cont[0];
201 $ar_id = (int)$cont[1];
203 $this->
addWhere(
"ar_rev_id $op $rev OR " .
204 "(ar_rev_id = $rev AND " .
205 "ar_id $op= $ar_id)" );
210 $title = $db->addQuotes( $cont[1] );
211 $ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
212 $ar_id = (int)$cont[3];
214 $this->
addWhere(
"ar_namespace $op $ns OR " .
215 "(ar_namespace = $ns AND " .
216 "(ar_title $op $title OR " .
217 "(ar_title = $title AND " .
218 "(ar_timestamp $op $ts OR " .
219 "(ar_timestamp = $ts AND " .
220 "ar_id $op= $ar_id)))))" );
224 $this->
addOption(
'LIMIT', $this->limit + 1 );
226 if ( $revCount !== 0 ) {
232 if ( count( $pageMap ) > 1 ) {
235 $oneTitle = key( reset( $pageMap ) );
236 foreach ( $pageMap as $pages ) {
237 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
250 foreach (
$res as $row ) {
251 if ( ++$count > $this->limit ) {
255 ?
"$row->ar_rev_id|$row->ar_id"
256 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
261 if ( $resultPageSet !==
null ) {
262 $generated[] = $row->ar_rev_id;
264 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
266 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
267 $converted = $pageSet->getConvertedTitles();
268 if (
$title && isset( $converted[
$title->getPrefixedText()] ) ) {
269 $title = Title::newFromText( $converted[
$title->getPrefixedText()] );
271 $pageMap[$row->ar_namespace][$row->ar_title] =
276 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
279 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
284 $pageMap[$row->ar_namespace][$row->ar_title],
285 $this->extractRevisionInfo( $this->revisionStore->newRevisionFromArchiveRow( $row ), $row ),
291 ?
"$row->ar_rev_id|$row->ar_id"
292 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
299 if ( $resultPageSet !==
null ) {
300 $resultPageSet->populateFromRevisionIDs( $generated );
305 return parent::getAllowedParams() + [
307 ParamValidator::PARAM_TYPE =>
'timestamp',
310 ParamValidator::PARAM_TYPE =>
'timestamp',
313 ParamValidator::PARAM_TYPE => [
317 ParamValidator::PARAM_DEFAULT =>
'older',
320 'newer' =>
'api-help-paramvalue-direction-newer',
321 'older' =>
'api-help-paramvalue-direction-older',
326 ParamValidator::PARAM_TYPE =>
'user',
327 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
330 ParamValidator::PARAM_TYPE =>
'user',
331 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
340 $title = Title::newMainPage();
341 $talkTitle =
$title->getTalkPageIfDefined();
346 $talkTitle = rawurlencode( $talkTitle->getPrefixedText() );
348 "action=query&prop=deletedrevisions&titles={$title}|{$talkTitle}&" .
349 'drvslots=*&drvprop=user|comment|content'
350 =>
'apihelp-query+deletedrevisions-example-titles',
354 return array_merge( $examples, [
355 'action=query&prop=deletedrevisions&revids=123456'
356 =>
'apihelp-query+deletedrevisions-example-revids',
361 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.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
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)
getExamplesMessages()
Returns usage examples for this module.
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.
A service to render content.
A service to transform content.