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', $this->getAuthority() )
110 if ( $params[
'tag'] !==
null ) {
111 if ( !$this->changeTagsStore->canViewTag( $params[
'tag'], $this->getAuthority() ) ) {
117 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
120 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
128 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
131 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
133 if ( $this->fetchContent && !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' ) ) {
134 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
137 $dir = $params[
'dir'];
139 if ( $revCount !== 0 ) {
141 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
145 $lb = $this->linkBatchFactory->newLinkBatch( $pageSet->getGoodAndMissingPages() );
146 $where = $lb->constructSet(
'ar', $db );
150 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
152 if ( $resultPageSet !==
null ) {
154 $this->
addJoinConds( [
'actor' => [
'JOIN',
'actor_id=ar_actor' ] ] );
156 if ( $params[
'user'] !==
null ) {
157 $this->
addWhereFld(
'actor_name', $params[
'user'] );
158 } elseif ( $params[
'excludeuser'] !==
null ) {
159 $this->
addWhere( $db->expr(
'actor_name',
'!=', $params[
'excludeuser'] ) );
163 if ( $params[
'user'] !==
null || $params[
'excludeuser'] !==
null ) {
165 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
166 $bitmask = RevisionRecord::DELETED_USER;
167 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
168 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
173 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
177 if ( $params[
'continue'] !==
null ) {
178 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
179 if ( $revCount !== 0 ) {
181 $this->
addWhere( $db->buildComparison( $op, [
182 'ar_rev_id' => $cont[0],
187 $this->
addWhere( $db->buildComparison( $op, [
188 'ar_namespace' => $cont[0],
189 'ar_title' => $cont[1],
190 'ar_timestamp' => $db->timestamp( $cont[2] ),
196 $this->
addOption(
'LIMIT', $this->limit + 1 );
198 if ( $revCount !== 0 ) {
204 if ( count( $pageMap ) > 1 ) {
207 $oneTitle = key( reset( $pageMap ) );
208 foreach ( $pageMap as $pages ) {
209 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
219 $res = $this->
select( __METHOD__ );
222 foreach ( $res as $row ) {
223 if ( ++$count > $this->limit ) {
227 ?
"$row->ar_rev_id|$row->ar_id"
228 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
233 if ( $resultPageSet !==
null ) {
234 $generated[] = $row->ar_rev_id;
236 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
239 $converted = $pageSet->getConvertedTitles();
240 if ( $title && isset( $converted[$title->getPrefixedText()] ) ) {
241 $title = Title::newFromText( $converted[$title->getPrefixedText()] );
242 if ( $title && isset( $pageMap[$title->getNamespace()][$title->getDBkey()] ) ) {
243 $pageMap[$row->ar_namespace][$row->ar_title] =
244 $pageMap[$title->getNamespace()][$title->getDBkey()];
248 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
251 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
256 $pageMap[$row->ar_namespace][$row->ar_title],
257 $this->extractRevisionInfo( $this->revisionStore->newRevisionFromArchiveRow( $row ), $row ),
263 ?
"$row->ar_rev_id|$row->ar_id"
264 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
271 if ( $resultPageSet !==
null ) {
272 $resultPageSet->populateFromRevisionIDs( $generated );
278 return parent::getAllowedParams() + [
280 ParamValidator::PARAM_TYPE =>
'timestamp',
283 ParamValidator::PARAM_TYPE =>
'timestamp',
286 ParamValidator::PARAM_TYPE => [
290 ParamValidator::PARAM_DEFAULT =>
'older',
293 'newer' =>
'api-help-paramvalue-direction-newer',
294 'older' =>
'api-help-paramvalue-direction-older',
299 ParamValidator::PARAM_TYPE =>
'user',
300 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
303 ParamValidator::PARAM_TYPE =>
'user',
304 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
314 $title = Title::newMainPage();
315 $talkTitle = $title->getTalkPageIfDefined();
317 'action=query&prop=deletedrevisions&revids=123456'
318 =>
'apihelp-query+deletedrevisions-example-revids',
322 $title = rawurlencode( $title->getPrefixedText() );
323 $talkTitle = rawurlencode( $talkTitle->getPrefixedText() );
324 $examples[
"action=query&prop=deletedrevisions&titles={$title}|{$talkTitle}&" .
325 'drvslots=*&drvprop=user|comment|content'] =
'apihelp-query+deletedrevisions-example-titles';
333 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Deletedrevisions';
338class_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.