79 $contentHandlerFactory,
88 $this->revisionStore = $revisionStore;
89 $this->changeTagDefStore = $changeTagDefStore;
90 $this->changeTagsStore = $changeTagsStore;
91 $this->linkBatchFactory = $linkBatchFactory;
96 $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
97 $pageCount = count( $pageSet->getGoodAndMissingPages() );
98 $revCount = $pageSet->getRevisionCount();
99 if ( $revCount === 0 && $pageCount === 0 ) {
103 if ( $revCount !== 0 && count( $pageSet->getDeletedRevisionIDs() ) === 0 ) {
110 $db = $this->
getDB();
114 if ( $resultPageSet ===
null ) {
116 $arQuery = $this->revisionStore->getArchiveQueryInfo();
120 $this->
addFields( [
'ar_title',
'ar_namespace' ] );
124 $this->
addFields( [
'ar_title',
'ar_namespace',
'ar_timestamp',
'ar_rev_id',
'ar_id' ] );
127 if ( $this->fld_tags ) {
129 'ts_tags' => $this->changeTagsStore->makeTagSummarySubquery(
'archive' )
133 if (
$params[
'tag'] !==
null ) {
136 [
'change_tag' => [
'JOIN', [
'ar_rev_id=ct_rev_id' ] ] ]
147 if ( ( $this->fld_comment || $this->fld_parsedcomment ) &&
150 $this->
dieWithError(
'apierror-cantview-deleted-comment',
'permissiondenied' );
152 if ( $this->fetchContent && !$this->
getAuthority()->isAllowedAny(
'deletedtext',
'undelete' ) ) {
153 $this->
dieWithError(
'apierror-cantview-deleted-revision-content',
'permissiondenied' );
158 if ( $revCount !== 0 ) {
160 'ar_rev_id' => array_keys( $pageSet->getDeletedRevisionIDs() )
164 $lb = $this->linkBatchFactory->newLinkBatch( $pageSet->getGoodAndMissingPages() );
165 $where = $lb->constructSet(
'ar', $db );
169 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
171 if ( $resultPageSet !==
null ) {
173 $this->
addJoinConds( [
'actor' => [
'JOIN',
'actor_id=ar_actor' ] ] );
175 if (
$params[
'user'] !==
null ) {
177 } elseif (
$params[
'excludeuser'] !==
null ) {
178 $this->
addWhere( $db->expr(
'actor_name',
'!=',
$params[
'excludeuser'] ) );
182 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
184 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
185 $bitmask = RevisionRecord::DELETED_USER;
186 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
187 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
192 $this->
addWhere( $db->bitAnd(
'ar_deleted', $bitmask ) .
" != $bitmask" );
196 if (
$params[
'continue'] !==
null ) {
197 $op = ( $dir ==
'newer' ?
'>=' :
'<=' );
198 if ( $revCount !== 0 ) {
200 $this->
addWhere( $db->buildComparison( $op, [
201 'ar_rev_id' => $cont[0],
206 $this->
addWhere( $db->buildComparison( $op, [
207 'ar_namespace' => $cont[0],
208 'ar_title' => $cont[1],
209 'ar_timestamp' => $db->timestamp( $cont[2] ),
215 $this->
addOption(
'LIMIT', $this->limit + 1 );
217 if ( $revCount !== 0 ) {
223 if ( count( $pageMap ) > 1 ) {
226 $oneTitle = key( reset( $pageMap ) );
227 foreach ( $pageMap as $pages ) {
228 if ( count( $pages ) > 1 || key( $pages ) !== $oneTitle ) {
238 $res = $this->
select( __METHOD__ );
241 foreach ( $res as $row ) {
242 if ( ++$count > $this->limit ) {
246 ?
"$row->ar_rev_id|$row->ar_id"
247 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
252 if ( $resultPageSet !==
null ) {
253 $generated[] = $row->ar_rev_id;
255 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
257 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
258 $converted = $pageSet->getConvertedTitles();
259 if ( $title && isset( $converted[$title->getPrefixedText()] ) ) {
260 $title = Title::newFromText( $converted[$title->getPrefixedText()] );
261 if ( $title && isset( $pageMap[$title->getNamespace()][$title->getDBkey()] ) ) {
262 $pageMap[$row->ar_namespace][$row->ar_title] =
263 $pageMap[$title->getNamespace()][$title->getDBkey()];
267 if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
270 "Found row in archive (ar_id={$row->ar_id}) that didn't get processed by ApiPageSet"
275 $pageMap[$row->ar_namespace][$row->ar_title],
276 $this->extractRevisionInfo( $this->revisionStore->newRevisionFromArchiveRow( $row ), $row ),
282 ?
"$row->ar_rev_id|$row->ar_id"
283 :
"$row->ar_namespace|$row->ar_title|$row->ar_timestamp|$row->ar_id"
290 if ( $resultPageSet !==
null ) {
291 $resultPageSet->populateFromRevisionIDs( $generated );
296 return parent::getAllowedParams() + [
298 ParamValidator::PARAM_TYPE =>
'timestamp',
301 ParamValidator::PARAM_TYPE =>
'timestamp',
304 ParamValidator::PARAM_TYPE => [
308 ParamValidator::PARAM_DEFAULT =>
'older',
311 'newer' =>
'api-help-paramvalue-direction-newer',
312 'older' =>
'api-help-paramvalue-direction-older',
317 ParamValidator::PARAM_TYPE =>
'user',
318 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
321 ParamValidator::PARAM_TYPE =>
'user',
322 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
331 $title = Title::newMainPage();
332 $talkTitle = $title->getTalkPageIfDefined();
334 'action=query&prop=deletedrevisions&revids=123456'
335 =>
'apihelp-query+deletedrevisions-example-revids',
339 $title = rawurlencode( $title->getPrefixedText() );
340 $talkTitle = rawurlencode( $talkTitle->getPrefixedText() );
341 $examples[
"action=query&prop=deletedrevisions&titles={$title}|{$talkTitle}&" .
342 'drvslots=*&drvprop=user|comment|content'] =
'apihelp-query+deletedrevisions-example-titles';
349 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Deletedrevisions';
354class_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.