59 $title = Title::newFromText( $term );
61 $ns =
$title->getNamespace();
62 $termMain =
$title->getText();
63 $termDb =
$title->getDBkey();
68 $termMain = $termDb = $term;
72 $engine = MediaWikiServices::getInstance()->newSearchEngine();
73 $engine->setLimitOffset( 100 );
74 $engine->setNamespaces( [ $ns ] );
75 $results = $engine->searchArchiveTitle( $termMain );
76 if ( !$results->isOK() ) {
79 $results = $results->getValue();
84 return self::listPagesByPrefix( $term );
88 $condTitles = array_unique( array_map(
static function (
Title $t ) {
89 return $t->getDBkey();
92 'ar_namespace' => $ns,
94 'ar_title' => $condTitles,
95 'ar_title' .
$dbr->buildLike( $termDb,
$dbr->anyString() ),
99 return self::listPages(
$dbr, $conds );
113 $title = Title::newFromText( $prefix );
115 $ns =
$title->getNamespace();
116 $prefix =
$title->getDBkey();
124 'ar_namespace' => $ns,
125 'ar_title' .
$dbr->buildLike( $prefix,
$dbr->anyString() ),
128 return self::listPages(
$dbr, $conds );
142 'count' =>
'COUNT(*)'
147 'GROUP BY' => [
'ar_namespace',
'ar_title' ],
148 'ORDER BY' => [
'ar_namespace',
'ar_title' ],
162 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
163 return $lookup->listRevisions( $this->title );
175 if ( $this->title->getNamespace() !==
NS_FILE ) {
179 $loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
183 $fileQuery[
'tables'],
184 $fileQuery[
'fields'],
185 [
'fa_name' => $this->title->getDBkey() ],
187 [
'ORDER BY' =>
'fa_timestamp DESC' ],
202 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
203 return $lookup->getRevisionRecordByTimestamp( $this->title, $timestamp );
216 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
217 return $lookup->getArchivedRevisionRecord( $this->title, $revId );
234 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
235 return $lookup->getPreviousRevisionRecord( $this->title, $timestamp );
245 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
246 return $lookup->getLastRevisionId( $this->title );
257 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
258 return $lookup->hasArchivedRevisions( $this->title );
291 $services = MediaWikiServices::getInstance();
292 $page = $services->getWikiPageFactory()->newFromTitle( $this->title );
293 $user = $services->getUserFactory()->newFromUserIdentity( $user );
294 $up = $services->getUndeletePageFactory()->newUndeletePage( $page, $user );
295 if ( is_string( $tags ) ) {
297 } elseif ( $tags ===
null ) {
301 ->setUndeleteOnlyTimestamps( $timestamps )
302 ->setUndeleteOnlyFileVersions( $fileVersions ?: [] )
303 ->setUnsuppress( $unsuppress )
304 ->setTags( $tags ?: [] )
305 ->undeleteUnsafe( $comment );
307 if ( $status->isGood() ) {
308 $restoredRevs = $status->getValue()[UndeletePage::REVISIONS_RESTORED];
309 $restoredFiles = $status->getValue()[UndeletePage::FILES_RESTORED];
310 if ( $restoredRevs === 0 && $restoredFiles === 0 ) {
313 $ret = [ $restoredRevs, $restoredFiles, $comment ];
318 $this->fileStatus = $up->getFileStatus();
319 $this->revisionStatus = $up->getRevisionStatus();
329 return $this->fileStatus;
338 return $this->revisionStatus;
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new archivedfile object.
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 listPages( $dbr, $condition)
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.
isDeleted()
Quick check if any archived revisions are present for the page.
Generic operation result class Has warning/error list, boolean status and arbitrary value.