48 private $revisionStore;
51 private $changeTagDefStore;
54 private $linkBatchFactory;
87 $contentHandlerFactory,
94 $this->revisionStore = $revisionStore;
95 $this->changeTagDefStore = $changeTagDefStore;
96 $this->linkBatchFactory = $linkBatchFactory;
101 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
102 $pageCount = count( $pageSet->getGoodAndMissingPages() );
103 $revCount = $pageSet->getRevisionCount();
104 if ( $revCount === 0 && $pageCount === 0 ) {
108 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
115 $db = $this->
getDB();
119 if ( $resultPageSet ===
null ) {
121 $arQuery = $this->revisionStore->getArchiveQueryInfo();
125 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
129 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
132 if ( $this->fld_tags ) {
136 if ( $params[
'tag'] !==
null ) {
139 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
142 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
150 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
153 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
155 if ( $this->fetchContent && !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' ) ) {
156 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
159 $dir = $params[
'dir'];
161 if ( $revCount !== 0 ) {
163 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
167 $lb = $this->linkBatchFactory->newLinkBatch( $pageSet->getGoodAndMissingPages() );
168 $where = $lb->constructSet(
'ar', $db );
172 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
174 if ( $resultPageSet !==
null ) {
176 $this->
addJoinConds( [
'actor' => [
'JOIN',
'actor_id=ar_actor' ] ] );
178 if ( $params[
'user'] !==
null ) {
179 $this->
addWhereFld(
'actor_name', $params[
'user'] );
180 } elseif ( $params[
'excludeuser'] !==
null ) {
181 $this->
addWhere(
'actor_name<>' . $db->addQuotes( $params[
'excludeuser'] ) );
185 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
187 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
188 $bitmask = RevisionRecord::DELETED_USER;
189 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
190 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
195 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
199 if ( $params[
'continue'] !==
null ) {
200 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
201 if ( $revCount !== 0 ) {
203 $this->
addWhere( $db->buildComparison( $op, [
204 'ar_rev_id' => $cont[0],
209 $this->
addWhere( $db->buildComparison( $op, [
210 'ar_namespace' => $cont[0],
211 'ar_title' => $cont[1],
212 'ar_timestamp' => $db->timestamp( $cont[2] ),
218 $this->
addOption(
'LIMIT', $this->limit + 1 );
220 if ( $revCount !== 0 ) {
226 if ( count( $pageMap ) > 1 ) {
229 $oneTitle = key( reset( $pageMap ) );
230 foreach ( $pageMap as $pages ) {
231 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
244 foreach (
$res as $row ) {
245 if ( ++$count > $this->limit ) {
249 ?
"$row->ar_rev_id|$row->ar_id"
250 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
255 if ( $resultPageSet !==
null ) {
256 $generated[] = $row->ar_rev_id;
258 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
260 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
261 $converted = $pageSet->getConvertedTitles();
262 if (
$title && isset( $converted[
$title->getPrefixedText()] ) ) {
263 $title = Title::newFromText( $converted[
$title->getPrefixedText()] );
265 $pageMap[$row->ar_namespace][$row->ar_title] =
270 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
273 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
278 $pageMap[$row->ar_namespace][$row->ar_title],
279 $this->extractRevisionInfo( $this->revisionStore->newRevisionFromArchiveRow( $row ), $row ),
285 ?
"$row->ar_rev_id|$row->ar_id"
286 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
293 if ( $resultPageSet !==
null ) {
294 $resultPageSet->populateFromRevisionIDs( $generated );
299 return parent::getAllowedParams() + [
301 ParamValidator::PARAM_TYPE =>
'timestamp',
304 ParamValidator::PARAM_TYPE =>
'timestamp',
307 ParamValidator::PARAM_TYPE => [
311 ParamValidator::PARAM_DEFAULT =>
'older',
314 'newer' =>
'api-help-paramvalue-direction-newer',
315 'older' =>
'api-help-paramvalue-direction-older',
320 ParamValidator::PARAM_TYPE =>
'user',
321 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
324 ParamValidator::PARAM_TYPE =>
'user',
325 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
334 $title = Title::newMainPage();
335 $talkTitle =
$title->getTalkPageIfDefined();
340 $talkTitle = rawurlencode( $talkTitle->getPrefixedText() );
342 "action=query&prop=deletedrevisions&titles={$title}|{$talkTitle}&" .
343 'drvslots=*&drvprop=user|comment|content'
344 =>
'apihelp-query+deletedrevisions-example-titles',
348 return array_merge( $examples, [
349 'action=query&prop=deletedrevisions&revids=123456'
350 =>
'apihelp-query+deletedrevisions-example-revids',
355 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.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
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, CommentFormatter $commentFormatter)
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.