77 $contentHandlerFactory,
86 $this->revisionStore = $revisionStore;
87 $this->changeTagDefStore = $changeTagDefStore;
88 $this->linkBatchFactory = $linkBatchFactory;
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 ) {
127 ->makeTagSummarySubquery(
'archive' )
131 if (
$params[
'tag'] !==
null ) {
134 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
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' );
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 ) {
175 } elseif (
$params[
'excludeuser'] !==
null ) {
176 $this->
addWhere( $db->expr(
'actor_name',
'!=',
$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 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
196 if ( $revCount !== 0 ) {
198 $this->
addWhere( $db->buildComparison( $op, [
199 'ar_rev_id' => $cont[0],
204 $this->
addWhere( $db->buildComparison( $op, [
205 'ar_namespace' => $cont[0],
206 'ar_title' => $cont[1],
207 'ar_timestamp' => $db->timestamp( $cont[2] ),
213 $this->
addOption(
'LIMIT', $this->limit + 1 );
215 if ( $revCount !== 0 ) {
221 if ( count( $pageMap ) > 1 ) {
224 $oneTitle = key( reset( $pageMap ) );
225 foreach ( $pageMap as $pages ) {
226 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
236 $res = $this->
select( __METHOD__ );
239 foreach ( $res as $row ) {
240 if ( ++$count > $this->limit ) {
244 ?
"$row->ar_rev_id|$row->ar_id"
245 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
250 if ( $resultPageSet !==
null ) {
251 $generated[] = $row->ar_rev_id;
253 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
255 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
256 $converted = $pageSet->getConvertedTitles();
257 if ( $title && isset( $converted[$title->getPrefixedText()] ) ) {
258 $title = Title::newFromText( $converted[$title->getPrefixedText()] );
259 if ( $title && isset( $pageMap[$title->getNamespace()][$title->getDBkey()] ) ) {
260 $pageMap[$row->ar_namespace][$row->ar_title] =
261 $pageMap[$title->getNamespace()][$title->getDBkey()];
265 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
268 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
273 $pageMap[$row->ar_namespace][$row->ar_title],
274 $this->extractRevisionInfo( $this->revisionStore->newRevisionFromArchiveRow( $row ), $row ),
280 ?
"$row->ar_rev_id|$row->ar_id"
281 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
288 if ( $resultPageSet !==
null ) {
289 $resultPageSet->populateFromRevisionIDs( $generated );
294 return parent::getAllowedParams() + [
296 ParamValidator::PARAM_TYPE =>
'timestamp',
299 ParamValidator::PARAM_TYPE =>
'timestamp',
302 ParamValidator::PARAM_TYPE => [
306 ParamValidator::PARAM_DEFAULT =>
'older',
309 'newer' =>
'api-help-paramvalue-direction-newer',
310 'older' =>
'api-help-paramvalue-direction-older',
315 ParamValidator::PARAM_TYPE =>
'user',
316 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
319 ParamValidator::PARAM_TYPE =>
'user',
320 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
329 $title = Title::newMainPage();
330 $talkTitle = $title->getTalkPageIfDefined();
332 'action=query&prop=deletedrevisions&revids=123456'
333 =>
'apihelp-query+deletedrevisions-example-revids',
337 $title = rawurlencode( $title->getPrefixedText() );
338 $talkTitle = rawurlencode( $talkTitle->getPrefixedText() );
339 $examples[
"action=query&prop=deletedrevisions&titles={$title}|{$talkTitle}&" .
340 'drvslots=*&drvprop=user|comment|content'] =
'apihelp-query+deletedrevisions-example-titles';
347 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Deletedrevisions';
352class_alias( ApiQueryDeletedRevisions::class,
'ApiQueryDeletedRevisions' );
array $params
The job parameters.
This class contains a list of pages that the client has requested.
A service to render content.
A service to transform content.