MediaWiki  master
PageArchive Class Reference

Used to show archived pages and eventually restore them. More...

Collaboration diagram for PageArchive:

Public Member Functions

 __construct (Title $title, Config $config=null)
 
 doesWrites ()
 
 getArchivedRevisionRecord (int $revId)
 Return the archived revision with the given ID. More...
 
 getFileStatus ()
 
 getLastRevisionId ()
 Returns the ID of the latest deleted revision. More...
 
 getPreviousRevisionRecord (string $timestamp)
 Return the most-previous revision, either live or deleted, against the deleted revision given by timestamp. More...
 
 getRevisionRecordByTimestamp ( $timestamp)
 Return a RevisionRecord object containing data for the deleted revision. More...
 
 getRevisionStatus ()
 
 isDeleted ()
 Quick check if any archived revisions are present for the page. More...
 
 listFiles ()
 List the deleted file revisions for this page, if it's a file page. More...
 
 listRevisions ()
 List the revisions of the given page. More...
 
 undeleteAsUser ( $timestamps, UserIdentity $user, $comment='', $fileVersions=[], $unsuppress=false, $tags=null)
 Restore the given (or all) text and file revisions for the page. More...
 

Static Public Member Functions

static listPagesByPrefix ( $prefix)
 List deleted pages recorded in the archive table matching the given title prefix. More...
 
static listPagesBySearch ( $term)
 List deleted pages recorded in the archive matching the given term, using search engine archive. More...
 

Static Protected Member Functions

static listPages ( $dbr, $condition)
 

Protected Attributes

Config $config
 
Status null $fileStatus
 
Status null $revisionStatus
 
Title $title
 

Private Member Functions

 getRevisionByConditions (array $conditions, array $options=[])
 
 undeleteRevisions ( $timestamps, $unsuppress=false, $comment='')
 This is the meaty bit – It restores archived revisions of the given page to the revision table. More...
 

Private Attributes

HookRunner $hookRunner
 
JobQueueGroup $jobQueueGroup
 
ILoadBalancer $loadBalancer
 
LoggerInterface $logger
 
ReadOnlyMode $readOnlyMode
 
RepoGroup $repoGroup
 
RevisionStore $revisionStore
 
UserFactory $userFactory
 
WikiPageFactory $wikiPageFactory
 

Detailed Description

Used to show archived pages and eventually restore them.

Definition at line 37 of file PageArchive.php.

Constructor & Destructor Documentation

◆ __construct()

PageArchive::__construct ( Title  $title,
Config  $config = null 
)
Parameters
Title$title
Config | null$config

Definition at line 82 of file PageArchive.php.

References $config, and $title.

Member Function Documentation

◆ doesWrites()

PageArchive::doesWrites ( )

Definition at line 112 of file PageArchive.php.

◆ getArchivedRevisionRecord()

PageArchive::getArchivedRevisionRecord ( int  $revId)

Return the archived revision with the given ID.

Since
1.35
Parameters
int$revId
Returns
RevisionRecord|null

Definition at line 306 of file PageArchive.php.

References getRevisionByConditions().

Referenced by getPreviousRevisionRecord().

◆ getFileStatus()

PageArchive::getFileStatus ( )
Returns
Status|null

Definition at line 817 of file PageArchive.php.

References $fileStatus.

◆ getLastRevisionId()

PageArchive::getLastRevisionId ( )

Returns the ID of the latest deleted revision.

Returns
int|false The revision's ID, or false if there is no deleted revision.

Definition at line 403 of file PageArchive.php.

References $dbr, and DB_REPLICA.

◆ getPreviousRevisionRecord()

PageArchive::getPreviousRevisionRecord ( string  $timestamp)

Return the most-previous revision, either live or deleted, against the deleted revision given by timestamp.

May produce unexpected results in case of history merges or other unusual time issues.

Since
1.35
Parameters
string$timestamp
Returns
RevisionRecord|null Null when there is no previous revision

Definition at line 353 of file PageArchive.php.

References $dbr, DB_REPLICA, getArchivedRevisionRecord(), and wfTimestamp().

◆ getRevisionByConditions()

PageArchive::getRevisionByConditions ( array  $conditions,
array  $options = [] 
)
private
Parameters
array$conditions
array$options
Returns
RevisionRecord|null

Definition at line 316 of file PageArchive.php.

References $dbr, and DB_REPLICA.

Referenced by getArchivedRevisionRecord(), and getRevisionRecordByTimestamp().

◆ getRevisionRecordByTimestamp()

PageArchive::getRevisionRecordByTimestamp (   $timestamp)

Return a RevisionRecord object containing data for the deleted revision.

Access: internal
only for use in SpecialUndelete
Parameters
string$timestamp
Returns
RevisionRecord|null

Definition at line 290 of file PageArchive.php.

References $dbr, DB_REPLICA, and getRevisionByConditions().

◆ getRevisionStatus()

PageArchive::getRevisionStatus ( )
Returns
Status|null

Definition at line 824 of file PageArchive.php.

References $revisionStatus.

◆ isDeleted()

PageArchive::isDeleted ( )

Quick check if any archived revisions are present for the page.

This says nothing about whether the page currently exists in the page table or not.

Returns
bool

Definition at line 423 of file PageArchive.php.

References $dbr, and DB_REPLICA.

◆ listFiles()

PageArchive::listFiles ( )

List the deleted file revisions for this page, if it's a file page.

Returns a result wrapper with various filearchive fields, or null if not a file page.

Returns
IResultWrapper|null
Todo:
Does this belong in Image for fuller encapsulation?

Definition at line 265 of file PageArchive.php.

References $dbr, DB_REPLICA, ArchivedFile\getQueryInfo(), and NS_FILE.

◆ listPages()

static PageArchive::listPages (   $dbr,
  $condition 
)
staticprotected
Parameters
IDatabase$dbr
string | array$condition
Returns
bool|IResultWrapper

Definition at line 200 of file PageArchive.php.

References $dbr.

Referenced by listPagesByPrefix(), and listPagesBySearch().

◆ listPagesByPrefix()

static PageArchive::listPagesByPrefix (   $prefix)
static

List deleted pages recorded in the archive table matching the given title prefix.

Returns result wrapper with (ar_namespace, ar_title, count) fields.

Parameters
string$prefixTitle prefix
Returns
IResultWrapper|bool

Definition at line 174 of file PageArchive.php.

References $dbr, $title, DB_REPLICA, Title\getDBkey(), Title\getNamespace(), listPages(), Title\newFromText(), and wfGetDB().

Referenced by listPagesBySearch(), and SpecialUndelete\showSearchForm().

◆ listPagesBySearch()

static PageArchive::listPagesBySearch (   $term)
static

List deleted pages recorded in the archive matching the given term, using search engine archive.

Returns result wrapper with (ar_namespace, ar_title, count) fields.

Parameters
string$termSearch term
Returns
IResultWrapper|bool

Definition at line 124 of file PageArchive.php.

References $dbr, $t, $title, DB_REPLICA, Title\getDBkey(), Title\getNamespace(), Title\getText(), LIST_OR, listPages(), listPagesByPrefix(), Title\newFromText(), and wfGetDB().

Referenced by SpecialUndelete\showSearchForm().

◆ listRevisions()

PageArchive::listRevisions ( )

List the revisions of the given page.

Returns result wrapper with various archive table fields.

Returns
IResultWrapper|bool

Definition at line 224 of file PageArchive.php.

References $dbr, DB_REPLICA, and ChangeTags\modifyDisplayQuery().

◆ undeleteAsUser()

PageArchive::undeleteAsUser (   $timestamps,
UserIdentity  $user,
  $comment = '',
  $fileVersions = [],
  $unsuppress = false,
  $tags = null 
)

Restore the given (or all) text and file revisions for the page.

Once restored, the items will be removed from the archive tables. The deletion log will be updated with an undeletion notice.

This also sets Status objects, $this->fileStatus and $this->revisionStatus (depending what operations are attempted).

Since
1.35
Parameters
array$timestampsPass an empty array to restore all revisions, otherwise list the ones to undelete.
UserIdentity$user
string$comment
array$fileVersions
bool$unsuppress
string | string[] | null$tagsChange tags to add to log entry ($user should be able to add the specified tags before this is called)
Returns
array|bool [ number of file revisions restored, number of image revisions restored, log message ] on success, false on failure.

Definition at line 457 of file PageArchive.php.

References NS_FILE, and undeleteRevisions().

◆ undeleteRevisions()

PageArchive::undeleteRevisions (   $timestamps,
  $unsuppress = false,
  $comment = '' 
)
private

This is the meaty bit – It restores archived revisions of the given page to the revision table.

Parameters
array$timestampsPass an empty array to restore all revisions, otherwise list the ones to undelete.
bool$unsuppressRemove all ar_deleted/fa_deleted restrictions of seletected revs
string$comment
Exceptions
ReadOnlyError
Returns
Status Status object containing the number of revisions restored on success

Definition at line 536 of file PageArchive.php.

References $content, $job, $revisionStore, DB_PRIMARY, MediaWiki\Revision\RevisionStore\getArchiveQueryInfo(), MediaWiki\Revision\RevisionStore\getTimestampFromId(), MediaWiki\Revision\RevisionStore\insertRevisionOn(), StatusValue\newFatal(), HTMLCacheUpdateJob\newForBacklinks(), StatusValue\newGood(), MediaWiki\Revision\RevisionStore\newRevisionFromArchiveRow(), NS_FILE, and wfMessage().

Referenced by undeleteAsUser().

Member Data Documentation

◆ $config

Config PageArchive::$config
protected

Definition at line 49 of file PageArchive.php.

Referenced by __construct().

◆ $fileStatus

Status null PageArchive::$fileStatus
protected

Definition at line 43 of file PageArchive.php.

Referenced by getFileStatus().

◆ $hookRunner

HookRunner PageArchive::$hookRunner
private

Definition at line 52 of file PageArchive.php.

◆ $jobQueueGroup

JobQueueGroup PageArchive::$jobQueueGroup
private

Definition at line 55 of file PageArchive.php.

◆ $loadBalancer

ILoadBalancer PageArchive::$loadBalancer
private

Definition at line 58 of file PageArchive.php.

◆ $logger

LoggerInterface PageArchive::$logger
private

Definition at line 61 of file PageArchive.php.

◆ $readOnlyMode

ReadOnlyMode PageArchive::$readOnlyMode
private

Definition at line 64 of file PageArchive.php.

◆ $repoGroup

RepoGroup PageArchive::$repoGroup
private

Definition at line 67 of file PageArchive.php.

◆ $revisionStatus

Status null PageArchive::$revisionStatus
protected

Definition at line 46 of file PageArchive.php.

Referenced by getRevisionStatus().

◆ $revisionStore

RevisionStore PageArchive::$revisionStore
private

Definition at line 70 of file PageArchive.php.

Referenced by undeleteRevisions().

◆ $title

Title PageArchive::$title
protected

Definition at line 40 of file PageArchive.php.

Referenced by __construct(), listPagesByPrefix(), and listPagesBySearch().

◆ $userFactory

UserFactory PageArchive::$userFactory
private

Definition at line 73 of file PageArchive.php.

◆ $wikiPageFactory

WikiPageFactory PageArchive::$wikiPageFactory
private

Definition at line 76 of file PageArchive.php.


The documentation for this class was generated from the following file: