MediaWiki fundraising/REL1_35
PageArchive Class Reference

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

Collaboration diagram for PageArchive:

Public Member Functions

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

Static Public Member Functions

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

Static Protected Member Functions

static listPages ( $dbr, $condition)
 

Protected Attributes

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

Private Member Functions

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

Detailed Description

Used to show archived pages and eventually restore them.

Definition at line 32 of file PageArchive.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 47 of file PageArchive.php.

References $title, and wfDebug().

Member Function Documentation

◆ doesWrites()

PageArchive::doesWrites ( )

Definition at line 70 of file PageArchive.php.

◆ getArchivedRevision()

PageArchive::getArchivedRevision ( $revId)

Return the archived revision with the given ID.

Deprecated
since 1.35, use getArchivedRevisionRecord instead
Parameters
int$revId
Returns
Revision|null

Definition at line 280 of file PageArchive.php.

References getArchivedRevisionRecord(), and wfDeprecated().

◆ 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 298 of file PageArchive.php.

References getRevisionByConditions().

Referenced by getArchivedRevision(), and getPreviousRevisionRecord().

◆ getFileStatus()

PageArchive::getFileStatus ( )
Returns
Status

Definition at line 907 of file PageArchive.php.

◆ 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 415 of file PageArchive.php.

References $dbr, DB_REPLICA, and wfGetDB().

◆ getPreviousRevision()

PageArchive::getPreviousRevision ( $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.

Deprecated
since 1.35, use getPreviousRevisionRecord
Parameters
string$timestamp
Returns
Revision|null Null when there is no previous revision

Definition at line 345 of file PageArchive.php.

References getPreviousRevisionRecord(), and wfDeprecated().

◆ 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 365 of file PageArchive.php.

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

Referenced by getPreviousRevision().

◆ getRevision()

PageArchive::getRevision ( $timestamp)

Return a Revision object containing data for the deleted revision.

Deprecated
since 1.32 (soft), 1.35 (hard) Use getArchivedRevisionRecord() instead if a revision id is available
Parameters
string$timestamp
Returns
Revision|null

Definition at line 250 of file PageArchive.php.

References getRevisionRecordByTimestamp(), and wfDeprecated().

◆ getRevisionByConditions()

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

Definition at line 308 of file PageArchive.php.

References $dbr, DB_REPLICA, getRevisionStore(), and wfGetDB().

Referenced by getArchivedRevisionRecord(), and getRevisionRecordByTimestamp().

◆ getRevisionRecordByTimestamp()

PageArchive::getRevisionRecordByTimestamp ( $timestamp)

Return a RevisionRecord object containing data for the deleted revision.

Definition at line 264 of file PageArchive.php.

References $dbr, DB_REPLICA, getRevisionByConditions(), and wfGetDB().

Referenced by getRevision().

◆ getRevisionStatus()

PageArchive::getRevisionStatus ( )
Returns
Status

Definition at line 914 of file PageArchive.php.

◆ getRevisionStore()

PageArchive::getRevisionStore ( )
private
Returns
RevisionStore

Definition at line 62 of file PageArchive.php.

Referenced by getPreviousRevisionRecord(), getRevisionByConditions(), listRevisions(), and undeleteRevisions().

◆ 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 435 of file PageArchive.php.

References $dbr, DB_REPLICA, and wfGetDB().

◆ 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
Todo
Does this belong in Image for fuller encapsulation?

Definition at line 224 of file PageArchive.php.

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

◆ listPages()

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

Definition at line 158 of file PageArchive.php.

References $dbr.

◆ 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

Definition at line 132 of file PageArchive.php.

References $dbr, $title, DB_REPLICA, and wfGetDB().

◆ 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

Definition at line 82 of file PageArchive.php.

References $dbr, $t, $title, DB_REPLICA, LIST_OR, and wfGetDB().

◆ listRevisions()

PageArchive::listRevisions ( )

List the revisions of the given page.

Returns result wrapper with various archive table fields.

Returns
IResultWrapper

Definition at line 182 of file PageArchive.php.

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

◆ undelete()

PageArchive::undelete ( $timestamps,
$comment = '',
$fileVersions = [],
$unsuppress = false,
User $user = null,
$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.

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

Deprecated
since 1.35, use ::undeleteAsUser
Parameters
array$timestampsPass an empty array to restore all revisions, otherwise list the ones to undelete.
string$comment
array$fileVersions
bool$unsuppress
User | null$userUser performing the action, or null to use $wgUser
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 469 of file PageArchive.php.

References undeleteAsUser(), and wfDeprecated().

◆ undeleteAsUser()

PageArchive::undeleteAsUser ( $timestamps,
User $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.
User$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 509 of file PageArchive.php.

References NS_FILE, undeleteRevisions(), and wfDebug().

Referenced by undelete().

◆ 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 588 of file PageArchive.php.

References $content, $job, DB_MASTER, getRevisionStore(), HTMLCacheUpdateJob\newForBacklinks(), NS_FILE, wfDebug(), wfGetDB(), wfMessage(), and wfReadOnly().

Referenced by undeleteAsUser().

Member Data Documentation

◆ $config

Config PageArchive::$config
protected

Definition at line 45 of file PageArchive.php.

◆ $fileStatus

Status PageArchive::$fileStatus
protected

Definition at line 39 of file PageArchive.php.

◆ $revisionStatus

Status PageArchive::$revisionStatus
protected

Definition at line 42 of file PageArchive.php.

◆ $title

Title PageArchive::$title
protected

Definition at line 36 of file PageArchive.php.


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