88 $contentHandlerFactory,
97 $this->revisionStore = $revisionStore;
98 $this->changeTagDefStore = $changeTagDefStore;
99 $this->linkBatchFactory = $linkBatchFactory;
104 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
105 $pageCount = count( $pageSet->getGoodAndMissingPages() );
106 $revCount = $pageSet->getRevisionCount();
107 if ( $revCount === 0 && $pageCount === 0 ) {
111 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
118 $db = $this->
getDB();
122 if ( $resultPageSet ===
null ) {
124 $arQuery = $this->revisionStore->getArchiveQueryInfo();
128 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
132 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
135 if ( $this->fld_tags ) {
139 if (
$params[
'tag'] !==
null ) {
142 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
153 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
156 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
158 if ( $this->fetchContent && !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' ) ) {
159 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
164 if ( $revCount !== 0 ) {
166 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
170 $lb = $this->linkBatchFactory->newLinkBatch( $pageSet->getGoodAndMissingPages() );
171 $where = $lb->constructSet(
'ar', $db );
175 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
177 if ( $resultPageSet !==
null ) {
179 $this->
addJoinConds( [
'actor' => [
'JOIN',
'actor_id=ar_actor' ] ] );
181 if (
$params[
'user'] !==
null ) {
183 } elseif (
$params[
'excludeuser'] !==
null ) {
184 $this->
addWhere( $db->expr(
'actor_name',
'!=',
$params[
'excludeuser'] ) );
188 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
190 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
191 $bitmask = RevisionRecord::DELETED_USER;
192 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
193 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
198 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
202 if (
$params[
'continue'] !==
null ) {
203 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
204 if ( $revCount !== 0 ) {
206 $this->
addWhere( $db->buildComparison( $op, [
207 'ar_rev_id' => $cont[0],
212 $this->
addWhere( $db->buildComparison( $op, [
213 'ar_namespace' => $cont[0],
214 'ar_title' => $cont[1],
215 'ar_timestamp' => $db->timestamp( $cont[2] ),
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 ) {
244 $res = $this->
select( __METHOD__ );
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()] );
267 if ( $title && isset( $pageMap[$title->getNamespace()][$title->getDBkey()] ) ) {
268 $pageMap[$row->ar_namespace][$row->ar_title] =
269 $pageMap[$title->getNamespace()][$title->getDBkey()];
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() + [
304 ParamValidator::PARAM_TYPE =>
'timestamp',
307 ParamValidator::PARAM_TYPE =>
'timestamp',
310 ParamValidator::PARAM_TYPE => [
314 ParamValidator::PARAM_DEFAULT =>
'older',
317 'newer' =>
'api-help-paramvalue-direction-newer',
318 'older' =>
'api-help-paramvalue-direction-older',
323 ParamValidator::PARAM_TYPE =>
'user',
324 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
327 ParamValidator::PARAM_TYPE =>
'user',
328 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
337 $title = Title::newMainPage();
338 $talkTitle = $title->getTalkPageIfDefined();
340 'action=query&prop=deletedrevisions&revids=123456'
341 =>
'apihelp-query+deletedrevisions-example-revids',
345 $title = rawurlencode( $title->getPrefixedText() );
346 $talkTitle = rawurlencode( $talkTitle->getPrefixedText() );
347 $examples[
"action=query&prop=deletedrevisions&titles={$title}|{$talkTitle}&" .
348 'drvslots=*&drvprop=user|comment|content'] =
'apihelp-query+deletedrevisions-example-titles';
355 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Deletedrevisions';
array $params
The job parameters.
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)
Dies if more than one parameter from a certain set of parameters are 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.
getExamplesMessages()
Returns usage examples for this module.
__construct(ApiQuery $query, $moduleName, RevisionStore $revisionStore, IContentHandlerFactory $contentHandlerFactory, ParserFactory $parserFactory, SlotRoleRegistry $slotRoleRegistry, NameTableStore $changeTagDefStore, LinkBatchFactory $linkBatchFactory, ContentRenderer $contentRenderer, ContentTransformer $contentTransformer, CommentFormatter $commentFormatter, TempUserCreator $tempUserCreator, UserFactory $userFactory)
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.