14use MediaWiki\Cache\LinkBatchFactory;
42 private LinkBatchFactory $linkBatchFactory;
53 LinkBatchFactory $linkBatchFactory,
65 $contentHandlerFactory,
74 $this->revisionStore = $revisionStore;
75 $this->changeTagDefStore = $changeTagDefStore;
76 $this->changeTagsStore = $changeTagsStore;
77 $this->linkBatchFactory = $linkBatchFactory;
82 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
83 $pageCount = count( $pageSet->getGoodAndMissingPages() );
84 $revCount = $pageSet->getRevisionCount();
85 if ( $revCount === 0 && $pageCount === 0 ) {
89 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
100 if ( $resultPageSet ===
null ) {
102 $arQuery = $this->revisionStore->getArchiveQueryInfo();
106 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
110 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
113 if ( $this->fld_tags ) {
115 'ts_tags' => $this->changeTagsStore->makeTagSummarySubquery(
'archive' )
119 if ( $params[
'tag'] !==
null ) {
122 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
125 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
133 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
136 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
138 if ( $this->fetchContent && !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' ) ) {
139 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
142 $dir = $params[
'dir'];
144 if ( $revCount !== 0 ) {
146 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
150 $lb = $this->linkBatchFactory->newLinkBatch( $pageSet->getGoodAndMissingPages() );
151 $where = $lb->constructSet(
'ar', $db );
155 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
157 if ( $resultPageSet !==
null ) {
159 $this->
addJoinConds( [
'actor' => [
'JOIN',
'actor_id=ar_actor' ] ] );
161 if ( $params[
'user'] !==
null ) {
162 $this->
addWhereFld(
'actor_name', $params[
'user'] );
163 } elseif ( $params[
'excludeuser'] !==
null ) {
164 $this->
addWhere( $db->expr(
'actor_name',
'!=', $params[
'excludeuser'] ) );
168 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
170 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
171 $bitmask = RevisionRecord::DELETED_USER;
172 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
173 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
178 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
182 if ( $params[
'continue'] !==
null ) {
183 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
184 if ( $revCount !== 0 ) {
186 $this->
addWhere( $db->buildComparison( $op, [
187 'ar_rev_id' => $cont[0],
192 $this->
addWhere( $db->buildComparison( $op, [
193 'ar_namespace' => $cont[0],
194 'ar_title' => $cont[1],
195 'ar_timestamp' => $db->timestamp( $cont[2] ),
201 $this->
addOption(
'LIMIT', $this->limit + 1 );
203 if ( $revCount !== 0 ) {
209 if ( count( $pageMap ) > 1 ) {
212 $oneTitle = key( reset( $pageMap ) );
213 foreach ( $pageMap as $pages ) {
214 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
224 $res = $this->
select( __METHOD__ );
227 foreach ( $res as $row ) {
228 if ( ++$count > $this->limit ) {
232 ?
"$row->ar_rev_id|$row->ar_id"
233 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
238 if ( $resultPageSet !==
null ) {
239 $generated[] = $row->ar_rev_id;
241 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
244 $converted = $pageSet->getConvertedTitles();
245 if ( $title && isset( $converted[$title->getPrefixedText()] ) ) {
246 $title = Title::newFromText( $converted[$title->getPrefixedText()] );
247 if ( $title && isset( $pageMap[$title->getNamespace()][$title->getDBkey()] ) ) {
248 $pageMap[$row->ar_namespace][$row->ar_title] =
249 $pageMap[$title->getNamespace()][$title->getDBkey()];
253 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
256 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
261 $pageMap[$row->ar_namespace][$row->ar_title],
262 $this->extractRevisionInfo( $this->revisionStore->newRevisionFromArchiveRow( $row ), $row ),
268 ?
"$row->ar_rev_id|$row->ar_id"
269 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
276 if ( $resultPageSet !==
null ) {
277 $resultPageSet->populateFromRevisionIDs( $generated );
283 return parent::getAllowedParams() + [
285 ParamValidator::PARAM_TYPE =>
'timestamp',
288 ParamValidator::PARAM_TYPE =>
'timestamp',
291 ParamValidator::PARAM_TYPE => [
295 ParamValidator::PARAM_DEFAULT =>
'older',
298 'newer' =>
'api-help-paramvalue-direction-newer',
299 'older' =>
'api-help-paramvalue-direction-older',
304 ParamValidator::PARAM_TYPE =>
'user',
305 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
308 ParamValidator::PARAM_TYPE =>
'user',
309 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
319 $title = Title::newMainPage();
320 $talkTitle = $title->getTalkPageIfDefined();
322 'action=query&prop=deletedrevisions&revids=123456'
323 =>
'apihelp-query+deletedrevisions-example-revids',
327 $title = rawurlencode( $title->getPrefixedText() );
328 $talkTitle = rawurlencode( $talkTitle->getPrefixedText() );
329 $examples[
"action=query&prop=deletedrevisions&titles={$title}|{$talkTitle}&" .
330 'drvslots=*&drvprop=user|comment|content'] =
'apihelp-query+deletedrevisions-example-titles';
338 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Deletedrevisions';
343class_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.