50 $this->title = $title;
62 $title = Title::newFromText( $term );
71 $termMain = $termDb = $term;
75 $engine = MediaWikiServices::getInstance()->newSearchEngine();
76 $engine->setLimitOffset( 100 );
77 $engine->setNamespaces( [ $ns ] );
78 $results = $engine->searchArchiveTitle( $termMain );
79 if ( !$results->isOK() ) {
82 $results = $results->getValue();
87 return self::listPagesByPrefix( $term );
90 $dbr = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getReplicaDatabase();
91 $condTitles = array_unique( array_map(
static function (
Title $t ) {
92 return $t->getDBkey();
95 'ar_namespace' => $ns,
97 'ar_title' => $condTitles,
98 'ar_title' . $dbr->buildLike( $termDb, $dbr->anyString() ),
102 return self::listPages( $dbr, $conds );
114 $dbr = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getReplicaDatabase();
116 $title = Title::newFromText( $prefix );
127 'ar_namespace' => $ns,
128 'ar_title' . $dbr->buildLike( $prefix, $dbr->anyString() ),
131 return self::listPages( $dbr, $conds );
141 ->select( [
'ar_namespace',
'ar_title',
'count' =>
'COUNT(*)' ] )
143 ->where( $condition )
144 ->groupBy( [
'ar_namespace',
'ar_title' ] )
145 ->orderBy( [
'ar_namespace',
'ar_title' ] )
147 ->caller( __METHOD__ )->fetchResultSet();
159 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
160 return $lookup->listRevisions( $this->title );
172 if ( $this->title->getNamespace() !==
NS_FILE ) {
176 $dbr = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getReplicaDatabase();
177 $queryBuilder = FileSelectQueryBuilder::newForArchivedFile( $dbr );
178 $queryBuilder->where( [
'fa_name' => $this->title->getDBkey() ] )
179 ->orderBy(
'fa_timestamp', SelectQueryBuilder::SORT_DESC );
180 return $queryBuilder->caller( __METHOD__ )->fetchResultSet();
194 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
195 return $lookup->getRevisionRecordByTimestamp( $this->title, $timestamp );
209 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
210 return $lookup->getArchivedRevisionRecord( $this->title, $revId );
228 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
229 return $lookup->getPreviousRevisionRecord( $this->title, $timestamp );
240 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
241 return $lookup->getLastRevisionId( $this->title );
253 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
254 return $lookup->hasArchivedRevisions( $this->title );
287 $services = MediaWikiServices::getInstance();
288 $page = $services->getWikiPageFactory()->newFromTitle( $this->title );
289 $user = $services->getUserFactory()->newFromUserIdentity( $user );
290 $up = $services->getUndeletePageFactory()->newUndeletePage( $page, $user );
291 if ( is_string( $tags ) ) {
293 } elseif ( $tags ===
null ) {
297 ->setUndeleteOnlyTimestamps( $timestamps )
298 ->setUndeleteOnlyFileVersions( $fileVersions ?: [] )
299 ->setUnsuppress( $unsuppress )
300 ->setTags( $tags ?: [] )
301 ->undeleteUnsafe( $comment );
303 if ( $status->isGood() ) {
304 $restoredRevs = $status->getValue()[UndeletePage::REVISIONS_RESTORED];
305 $restoredFiles = $status->getValue()[UndeletePage::FILES_RESTORED];
306 if ( $restoredRevs === 0 && $restoredFiles === 0 ) {
309 $ret = [ $restoredRevs, $restoredFiles, $comment ];
314 $this->fileStatus = $up->getFileStatus();
315 $this->revisionStatus = $up->getRevisionStatus();
325 return $this->fileStatus;
334 return $this->revisionStatus;
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Backend logic for performing a page undelete action.
Used to show archived pages and eventually restore them.
Status null $revisionStatus
listFiles()
List the deleted file revisions for this page, if it's a file page.
getPreviousRevisionRecord(string $timestamp)
Return the most-previous revision, either live or deleted, against the deleted revision given by time...
undeleteAsUser( $timestamps, UserIdentity $user, $comment='', $fileVersions=[], $unsuppress=false, $tags=null)
Restore the given (or all) text and file revisions for the page.
static listPagesBySearch( $term)
List deleted pages recorded in the archive matching the given term, using search engine archive.
getArchivedRevisionRecord(int $revId)
Return the archived revision with the given ID.
getRevisionRecordByTimestamp( $timestamp)
Return a RevisionRecord object containing data for the deleted revision.
getLastRevisionId()
Returns the ID of the latest deleted revision.
__construct(Title $title)
listRevisions()
List the revisions of the given page.
static listPagesByPrefix( $prefix)
List deleted pages recorded in the archive table matching the given title prefix.
static listPages(IReadableDatabase $dbr, $condition)
isDeleted()
Quick check if any archived revisions are present for the page.