60 $contentHandlerFactory,
73 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
74 $pageCount = count( $pageSet->getGoodAndMissingPages() );
75 $revCount = $pageSet->getRevisionCount();
76 if ( $revCount === 0 && $pageCount === 0 ) {
80 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
91 if ( $resultPageSet ===
null ) {
93 $arQuery = $this->revisionStore->getArchiveQueryInfo();
97 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
101 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
104 if ( $this->fld_tags ) {
106 'ts_tags' => $this->changeTagsStore->makeTagSummarySubquery(
'archive' )
110 if ( $params[
'tag'] !==
null ) {
113 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
116 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
124 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
127 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
129 if ( $this->fetchContent && !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' ) ) {
130 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
133 $dir = $params[
'dir'];
135 if ( $revCount !== 0 ) {
137 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
141 $lb = $this->linkBatchFactory->newLinkBatch( $pageSet->getGoodAndMissingPages() );
142 $where = $lb->constructSet(
'ar', $db );
146 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
148 if ( $resultPageSet !==
null ) {
150 $this->
addJoinConds( [
'actor' => [
'JOIN',
'actor_id=ar_actor' ] ] );
152 if ( $params[
'user'] !==
null ) {
153 $this->
addWhereFld(
'actor_name', $params[
'user'] );
154 } elseif ( $params[
'excludeuser'] !==
null ) {
155 $this->
addWhere( $db->expr(
'actor_name',
'!=', $params[
'excludeuser'] ) );
159 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
161 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
162 $bitmask = RevisionRecord::DELETED_USER;
163 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
164 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
169 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
173 if ( $params[
'continue'] !==
null ) {
174 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
175 if ( $revCount !== 0 ) {
177 $this->
addWhere( $db->buildComparison( $op, [
178 'ar_rev_id' => $cont[0],
183 $this->
addWhere( $db->buildComparison( $op, [
184 'ar_namespace' => $cont[0],
185 'ar_title' => $cont[1],
186 'ar_timestamp' => $db->timestamp( $cont[2] ),
192 $this->
addOption(
'LIMIT', $this->limit + 1 );
194 if ( $revCount !== 0 ) {
200 if ( count( $pageMap ) > 1 ) {
203 $oneTitle = key( reset( $pageMap ) );
204 foreach ( $pageMap as $pages ) {
205 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
215 $res = $this->
select( __METHOD__ );
218 foreach ( $res as $row ) {
219 if ( ++$count > $this->limit ) {
223 ?
"$row->ar_rev_id|$row->ar_id"
224 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
229 if ( $resultPageSet !==
null ) {
230 $generated[] = $row->ar_rev_id;
232 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
235 $converted = $pageSet->getConvertedTitles();
236 if ( $title && isset( $converted[$title->getPrefixedText()] ) ) {
237 $title = Title::newFromText( $converted[$title->getPrefixedText()] );
238 if ( $title && isset( $pageMap[$title->getNamespace()][$title->getDBkey()] ) ) {
239 $pageMap[$row->ar_namespace][$row->ar_title] =
240 $pageMap[$title->getNamespace()][$title->getDBkey()];
244 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
247 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
252 $pageMap[$row->ar_namespace][$row->ar_title],
253 $this->extractRevisionInfo( $this->revisionStore->newRevisionFromArchiveRow( $row ), $row ),
259 ?
"$row->ar_rev_id|$row->ar_id"
260 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
267 if ( $resultPageSet !==
null ) {
268 $resultPageSet->populateFromRevisionIDs( $generated );
274 return parent::getAllowedParams() + [
276 ParamValidator::PARAM_TYPE =>
'timestamp',
279 ParamValidator::PARAM_TYPE =>
'timestamp',
282 ParamValidator::PARAM_TYPE => [
286 ParamValidator::PARAM_DEFAULT =>
'older',
289 'newer' =>
'api-help-paramvalue-direction-newer',
290 'older' =>
'api-help-paramvalue-direction-older',
295 ParamValidator::PARAM_TYPE =>
'user',
296 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
299 ParamValidator::PARAM_TYPE =>
'user',
300 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
310 $title = Title::newMainPage();
311 $talkTitle = $title->getTalkPageIfDefined();
313 'action=query&prop=deletedrevisions&revids=123456'
314 =>
'apihelp-query+deletedrevisions-example-revids',
318 $title = rawurlencode( $title->getPrefixedText() );
319 $talkTitle = rawurlencode( $talkTitle->getPrefixedText() );
320 $examples[
"action=query&prop=deletedrevisions&titles={$title}|{$talkTitle}&" .
321 'drvslots=*&drvprop=user|comment|content'] =
'apihelp-query+deletedrevisions-example-titles';
329 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Deletedrevisions';
334class_alias( ApiQueryDeletedRevisions::class,
'ApiQueryDeletedRevisions' );
This class contains a list of pages that the client has requested.
A service to render content.
A service to transform content.
Factory for LinkBatch objects to batch query page metadata.