67 $termMain = $termDb = $term;
71 $engine = MediaWikiServices::getInstance()->newSearchEngine();
72 $engine->setLimitOffset( 100 );
73 $engine->setNamespaces( [ $ns ] );
74 $results = $engine->searchArchiveTitle( $termMain );
75 if ( !$results->isOK() ) {
78 $results = $results->getValue();
87 $condTitles = array_unique( array_map(
static function (
Title $t ) {
88 return $t->getDBkey();
91 'ar_namespace' => $ns,
92 $dbr->makeList( [
'ar_title' => $condTitles ],
LIST_OR ) .
" OR ar_title " .
93 $dbr->buildLike( $termDb,
$dbr->anyString() )
121 'ar_namespace' => $ns,
122 'ar_title' .
$dbr->buildLike( $prefix,
$dbr->anyString() ),
139 'count' =>
'COUNT(*)'
144 'GROUP BY' => [
'ar_namespace',
'ar_title' ],
145 'ORDER BY' => [
'ar_namespace',
'ar_title' ],
159 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
160 return $lookup->listRevisions( $this->title );
172 if ( $this->title->getNamespace() !==
NS_FILE ) {
176 $loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
180 $fileQuery[
'tables'],
181 $fileQuery[
'fields'],
182 [
'fa_name' => $this->title->getDBkey() ],
184 [
'ORDER BY' =>
'fa_timestamp DESC' ],
199 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
200 return $lookup->getRevisionRecordByTimestamp( $this->title, $timestamp );
213 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
214 return $lookup->getArchivedRevisionRecord( $this->title, $revId );
231 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
232 return $lookup->getPreviousRevisionRecord( $this->title, $timestamp );
242 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
243 return $lookup->getLastRevisionId( $this->title );
254 $lookup = MediaWikiServices::getInstance()->getArchivedRevisionLookup();
255 return $lookup->hasArchivedRevisions( $this->title );
288 $services = MediaWikiServices::getInstance();
289 $page = $services->getWikiPageFactory()->newFromTitle( $this->title );
290 $user = $services->getUserFactory()->newFromUserIdentity( $user );
291 $up = $services->getUndeletePageFactory()->newUndeletePage( $page, $user );
292 if ( is_string( $tags ) ) {
294 } elseif ( $tags ===
null ) {
298 ->setUndeleteOnlyTimestamps( $timestamps )
299 ->setUndeleteOnlyFileVersions( $fileVersions ?: [] )
300 ->setUnsuppress( $unsuppress )
301 ->setTags( $tags ?: [] )
302 ->undeleteUnsafe( $comment );
304 if ( $status->isGood() ) {
305 $restoredRevs = $status->getValue()[UndeletePage::REVISIONS_RESTORED];
306 $restoredFiles = $status->getValue()[UndeletePage::FILES_RESTORED];
307 if ( $restoredRevs === 0 && $restoredFiles === 0 ) {
310 $ret = [ $restoredRevs, $restoredFiles, $comment ];
315 $this->fileStatus = $up->getFileStatus();
316 $this->revisionStatus = $up->getRevisionStatus();
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.
Represents a title within MediaWiki.
getNamespace()
Get the namespace index, i.e.
getDBkey()
Get the main part with underscores.
getText()
Get the text form (spaces not underscores) of the main part.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.