MediaWiki  master
Revision Class Reference
Inheritance diagram for Revision:
Collaboration diagram for Revision:

Public Member Functions

 __construct ($row, $queryFlags=0, Title $title=null)
 
 getComment ($audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision comment if it's available to the specified audience. More...
 
 getContent ($audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision content if it's available to the specified audience. More...
 
 getContentFormat ()
 Returns the content format for the main slot of this revision. More...
 
 getContentHandler ()
 Returns the content handler appropriate for this revision's content model. More...
 
 getContentModel ()
 Returns the content model for the main slot of this revision. More...
 
 getId ()
 Get revision ID. More...
 
 getNext ()
 Get next revision for this title. More...
 
 getPage ()
 Get the page ID. More...
 
 getParentId ()
 Get parent revision ID (the original previous page revision) More...
 
 getPrevious ()
 Get previous revision for this title. More...
 
 getRecentChange ($flags=0)
 Get the RC object belonging to the current revision, if there's one. More...
 
 getRevisionRecord ()
 
 getSerializedData ()
 Get original serialized data (without checking view restrictions) More...
 
 getSha1 ()
 Returns the base36 sha1 of the content in this revision, or null if unknown. More...
 
 getSize ()
 Returns the length of the text in this revision, or null if unknown. More...
 
 getTextId ()
 Get the ID of the row of the text table that contains the content of the revision's main slot, if that content is stored in the text table. More...
 
 getTimestamp ()
 
 getTitle ()
 Returns the title of the page associated with this entry. More...
 
 getUser ($audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision's user id if it's available to the specified audience. More...
 
 getUserText ($audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision's username if it's available to the specified audience. More...
 
 getVisibility ()
 Get the deletion bitfield of the revision. More...
 
 insertOn ($dbw)
 Insert a new revision into the database, returning the new revision ID number on success and dies horribly on failure. More...
 
 isCurrent ()
 
 isDeleted ($field)
 
 isMinor ()
 
 isUnpatrolled ()
 
 setId ($id)
 Set the revision ID. More...
 
 setTitle ($title)
 Set the title of the revision. More...
 
 setUserIdAndName ($id, $name)
 Set the user ID/name. More...
 
 userCan ($field, User $user=null)
 Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted. More...
 

Static Public Member Functions

static base36Sha1 ($text)
 Get the base 36 SHA-1 value for a string of text. More...
 
static compressRevisionText (&$text)
 If $wgCompressRevisions is enabled, we will compress data. More...
 
static countByPageId ($db, $id)
 Get count of revisions per page...not very efficient. More...
 
static countByTitle ($db, $title)
 Get count of revisions per page...not very efficient. More...
 
static decompressRevisionText ($text, $flags)
 Re-converts revision text according to it's flags. More...
 
static fetchRevision (LinkTarget $title)
 Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn. More...
 
static getArchiveQueryInfo ()
 Return the tables, fields, and join conditions to be selected to create a new archived revision object. More...
 
static getParentLengths ($db, array $revIds)
 Do a batched query to get the parent revision lengths. More...
 
static getQueryInfo ($options=[])
 Return the tables, fields, and join conditions to be selected to create a new revision object. More...
 
static getRevisionText ($row, $prefix= 'old_', $wiki=false)
 Get revision text associated with an old or archive row. More...
 
static getTimestampFromId ($title, $id, $flags=0)
 Get rev_timestamp from rev_id, without loading the rest of the row. More...
 
static loadFromId ($db, $id)
 Load a page revision from a given revision ID number. More...
 
static loadFromPageId ($db, $pageid, $id=0)
 Load either the current, or a specified, revision that's attached to a given page. More...
 
static loadFromTimestamp ($db, $title, $timestamp)
 Load the revision for the given title with the given timestamp. More...
 
static loadFromTitle ($db, $title, $id=0)
 Load either the current, or a specified, revision that's attached to a given page. More...
 
static newFromArchiveRow ($row, $overrides=[])
 Make a fake revision object from an archive table row. More...
 
static newFromId ($id, $flags=0)
 Load a page revision from a given revision ID number. More...
 
static newFromPageId ($pageId, $revId=0, $flags=0)
 Load either the current, or a specified, revision that's attached to a given page ID. More...
 
static newFromRow ($row)
 
static newFromTitle (LinkTarget $linkTarget, $id=0, $flags=0)
 Load either the current, or a specified, revision that's attached to a given link target. More...
 
static newKnownCurrent (IDatabase $db, $pageIdOrTitle, $revId=0)
 Load a revision based on a known page ID and current revision ID from the DB. More...
 
static newNullRevision ($dbw, $pageId, $summary, $minor, $user=null)
 Create a new null-revision for insertion into a page's history. More...
 
static pageJoinCond ()
 Return the value of a select() page conds array for the page table. More...
 
static selectArchiveFields ()
 Return the list of revision fields that should be selected to create a new revision from an archive row. More...
 
static selectFields ()
 Return the list of revision fields that should be selected to create a new revision. More...
 
static selectPageFields ()
 Return the list of page fields that should be selected from page table. More...
 
static selectTextFields ()
 Return the list of text fields that should be selected to read the revision text. More...
 
static selectUserFields ()
 Return the list of user fields that should be selected from user table. More...
 
static userCanBitfield ($bitfield, $field, User $user=null, Title $title=null)
 Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted. More...
 
static userJoinCond ()
 Return the value of a select() JOIN conds array for the user table. More...
 
static userWasLastToEdit ($db, $pageId, $userId, $since)
 Check if no edits were made by other users since the time a user started editing the page. More...
 

Public Attributes

const DELETED_COMMENT = RevisionRecord::DELETED_COMMENT
 
const DELETED_RESTRICTED = RevisionRecord::DELETED_RESTRICTED
 
const DELETED_TEXT = RevisionRecord::DELETED_TEXT
 
const DELETED_USER = RevisionRecord::DELETED_USER
 
const FOR_PUBLIC = RevisionRecord::FOR_PUBLIC
 
const FOR_THIS_USER = RevisionRecord::FOR_THIS_USER
 
const RAW = RevisionRecord::RAW
 
const SUPPRESSED_ALL = RevisionRecord::SUPPRESSED_ALL
 
const SUPPRESSED_USER = RevisionRecord::SUPPRESSED_USER
 
const TEXT_CACHE_GROUP = SqlBlobStore::TEXT_CACHE_GROUP
 
- Public Attributes inherited from IDBAccessObject
const READ_LOCKING = 3
 Constants for object loading bitfield flags (higher => higher QoS) More...
 
const READ_NONE = -1
 

Static Protected Member Functions

static getBlobStore ($wiki=false)
 
static getRevisionFactory ()
 
static getRevisionLookup ()
 
static getRevisionStore ()
 

Protected Attributes

RevisionRecord $mRecord
 

Private Member Functions

 ensureTitle ($row, $queryFlags, $title=null)
 Make sure we have some Title object for use by the constructor. More...
 
 getMainSlotRaw ()
 

Detailed Description

Deprecated:
since 1.31, use RevisionRecord, RevisionStore, and BlobStore instead.

Definition at line 41 of file Revision.php.

Constructor & Destructor Documentation

Revision::__construct (   $row,
  $queryFlags = 0,
Title  $title = null 
)
Parameters
object | array | RevisionRecord$rowEither a database row or an array
int$queryFlags
Title | null$title
Access:
private

Definition at line 530 of file Revision.php.

References $title, ensureTitle(), and global.

Member Function Documentation

static Revision::base36Sha1 (   $text)
static

Get the base 36 SHA-1 value for a string of text.

Parameters
string$text
Returns
string

Definition at line 1108 of file Revision.php.

Referenced by RevisionDbTestBase\provideGetSha1(), PopulateRevisionSha1\upgradeLegacyArchiveRow(), and PopulateRevisionSha1\upgradeRow().

static Revision::compressRevisionText ( $text)
static

If $wgCompressRevisions is enabled, we will compress data.

The input string is modified in place. Return value is the flags field: contains 'gzip' if the data is compressed, and 'utf-8' if we're saving in UTF-8 mode.

Parameters
mixed&$textReference to a text
Returns
string

Definition at line 1054 of file Revision.php.

Referenced by MigrateArchiveText\doDBUpdates(), CheckStorage\importRevision(), RevisionTest\testCompressRevisionTextUtf8(), and RevisionTest\testCompressRevisionTextUtf8Gzip().

static Revision::countByPageId (   $db,
  $id 
)
static

Get count of revisions per page...not very efficient.

Parameters
IDatabase$db
int$idPage id
Returns
int

Definition at line 1204 of file Revision.php.

static Revision::countByTitle (   $db,
  $title 
)
static

Get count of revisions per page...not very efficient.

Parameters
IDatabase$db
Title$title
Returns
int

Definition at line 1215 of file Revision.php.

References $title.

static Revision::decompressRevisionText (   $text,
  $flags 
)
static

Re-converts revision text according to it's flags.

Parameters
mixed$textReference to a text
array$flagsCompression flags
Returns
string|bool Decompressed text, or false on failure

Definition at line 1065 of file Revision.php.

Referenced by RevisionTest\testDecompressRevisionText().

Revision::ensureTitle (   $row,
  $queryFlags,
  $title = null 
)
private

Make sure we have some Title object for use by the constructor.

For B/C, the constructor shouldn't fail even for a bad page ID or bad revision ID.

Parameters
array | object$row
int$queryFlags
Title | null$title
Returns
Title $title if not null, or a Title constructed from information in $row.

Definition at line 570 of file Revision.php.

References $title, Title\makeTitleSafe(), NS_SPECIAL, and wfLogWarning().

Referenced by __construct().

static Revision::fetchRevision ( LinkTarget  $title)
static

Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn.

Each row can be fed to the constructor to get objects.

Parameters
LinkTarget$title
Returns
ResultWrapper
Deprecated:
Since 1.28, no callers in core nor in known extensions. No-op since 1.31.

Definition at line 305 of file Revision.php.

References wfDeprecated().

Referenced by RevisionDbTestBase\testFetchRevision().

static Revision::getArchiveQueryInfo ( )
static

Return the tables, fields, and join conditions to be selected to create a new archived revision object.

Since
1.31
Deprecated:
since 1.31, use RevisionStore::getArchiveQueryInfo() instead.
Returns
array With three keys:
  • tables: (string[]) to include in the $table to IDatabase->select()
  • fields: (string[]) to include in the $vars to IDatabase->select()
  • joins: (array) to include in the $join_conds to IDatabase->select()

Definition at line 506 of file Revision.php.

Referenced by DifferenceEngine\deletedLink(), PopulateRevisionSha1\doDBUpdates(), PopulateRevisionLength\doDBUpdates(), RevDelArchiveList\doQuery(), RevDelRevisionList\doQuery(), PopulateRevisionSha1\doSha1LegacyUpdates(), ApiComparePages\getDiffContent(), PageArchive\getRevision(), ApiComparePages\guessTitleAndModel(), ApiQueryDeletedRevisions\run(), ApiQueryAllDeletedRevisions\run(), RevisionTest\testGetArchiveQueryInfo(), RevisionDbTestBase\testNewFromArchiveRow(), RevisionDbTestBase\testNewFromArchiveRowOverrides(), and PageArchiveTest\testUndeleteRevisions().

static Revision::getBlobStore (   $wiki = false)
staticprotected
Parameters
bool | string$wikiThe ID of the target wiki database. Use false for the local wiki.
Returns
SqlBlobStore

Definition at line 87 of file Revision.php.

Revision::getComment (   $audience = self::FOR_PUBLIC,
User  $user = null 
)

Fetch revision comment if it's available to the specified audience.

If the specified audience does not have access to the comment, an empty string will be returned.

Parameters
int$audienceOne of: Revision::FOR_PUBLIC to be displayed to all users Revision::FOR_THIS_USER to be displayed to the given user Revision::RAW get the text regardless of permissions
User | null$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
string

Definition at line 825 of file Revision.php.

References $user, and global.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), ApiQueryRevisionsBase\extractRevisionInfo(), Linker\revComment(), and MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow().

Revision::getContent (   $audience = self::FOR_PUBLIC,
User  $user = null 
)

Fetch revision content if it's available to the specified audience.

If the specified audience does not have the ability to view this revision, or the content could not be loaded, null will be returned.

Parameters
int$audienceOne of: Revision::FOR_PUBLIC to be displayed to all users Revision::FOR_THIS_USER to be displayed to $user Revision::RAW get the text regardless of permissions
User$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Since
1.21
Returns
Content|null

Definition at line 895 of file Revision.php.

References $e, $user, and global.

Referenced by WikiPage\doEditUpdates(), ApiQueryRevisionsBase\extractRevisionInfo(), CategoryMembershipChangeJob\getCategoriesAtRev(), ContentHandler\getUndoContent(), CategoryMembershipChangeJob\notifyUpdatesForRevision(), and BenchmarkParse\runParser().

Revision::getContentFormat ( )

Returns the content format for the main slot of this revision.

If no content format was stored in the database, the default format for this revision's content model is returned.

Todo:
: drop this, the format is irrelevant to the revision!
Returns
string The content format id associated with this revision, see the CONTENT_FORMAT_XXX constants.

Definition at line 950 of file Revision.php.

References getContentHandler(), and getMainSlotRaw().

Referenced by RevisionDbTestBase\assertRevEquals(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), and MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow().

Revision::getContentHandler ( )

Returns the content handler appropriate for this revision's content model.

Exceptions
MWException
Returns
ContentHandler

Definition at line 967 of file Revision.php.

References getContentModel(), and ContentHandler\getForModelID().

Referenced by ApiQueryRevisionsBase\extractRevisionInfo(), getContentFormat(), and WikiPage\getUndoContent().

Revision::getContentModel ( )

Returns the content model for the main slot of this revision.

If no content model was stored in the database, the default content model for the title is used to determine the content model to use. If no title is know, CONTENT_MODEL_WIKITEXT is used as a last resort.

Todo:
: drop this, with MCR, there no longer is a single model associated with a revision.
Returns
string The content model id associated with this revision, see the CONTENT_MODEL_XXX constants.

Definition at line 935 of file Revision.php.

References getMainSlotRaw().

Referenced by RevisionDbTestBase\assertRevEquals(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), ApiQueryRevisionsBase\extractRevisionInfo(), getContentHandler(), and MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow().

Revision::getMainSlotRaw ( )
private
Returns
SlotRecord

Definition at line 667 of file Revision.php.

Referenced by getContentFormat(), getContentModel(), getSerializedData(), and getTextId().

Revision::getNext ( )

Get next revision for this title.

Returns
Revision|null

Definition at line 1001 of file Revision.php.

References $title, and getTitle().

Revision::getParentId ( )

Get parent revision ID (the original previous page revision)

Returns
int|null The ID of the parent revision. 0 indicates that there is no parent revision. Null indicates that the parent revision is not known.

Definition at line 696 of file Revision.php.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), ApiQueryRevisionsBase\extractRevisionInfo(), CategoryMembershipChangeJob\notifyUpdatesForRevision(), and MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow().

static Revision::getParentLengths (   $db,
array  $revIds 
)
static

Do a batched query to get the parent revision lengths.

Deprecated:
in 1.31, use RevisionStore::getRevisionSizes instead.
Parameters
IDatabase$db
array$revIds
Returns
array

Definition at line 519 of file Revision.php.

Referenced by ContribsPager\doBatchLookups(), HistoryPager\doBatchLookups(), ApiQueryContributions\execute(), RevisionDbTestBase\testGetParentLengths_multipleRevIds(), RevisionDbTestBase\testGetParentLengths_noRevIds(), and RevisionDbTestBase\testGetParentLengths_oneRevId().

Revision::getPrevious ( )

Get previous revision for this title.

Returns
Revision|null

Definition at line 990 of file Revision.php.

References $title, and getTitle().

static Revision::getQueryInfo (   $options = [])
static

Return the tables, fields, and join conditions to be selected to create a new revision object.

Since
1.31
Deprecated:
since 1.31, use RevisionStore::getQueryInfo() instead.
Parameters
array$optionsAny combination of the following strings
  • 'page': Join with the page table, and select fields to identify the page
  • 'user': Join with the user table, and select the user name
  • 'text': Join with the text table, and select fields to load page text
Returns
array With three keys:
  • tables: (string[]) to include in the $table to IDatabase->select()
  • fields: (string[]) to include in the $vars to IDatabase->select()
  • joins: (array) to include in the $join_conds to IDatabase->select()

Definition at line 492 of file Revision.php.

References $options.

Referenced by WikiExporter\do_list_authors(), PopulateRevisionSha1\doDBUpdates(), PopulateRevisionLength\doDBUpdates(), WikiPage\doDeleteArticleReal(), ChangeTagsRevisionList\doQuery(), RevDelRevisionList\doQuery(), RevisionList\doQuery(), WikiExporter\dumpFrom(), ApiQueryContributors\execute(), HistoryAction\fetchRevisions(), Title\getAuthorsBetween(), ContentHandler\getAutoDeleteReason(), Title\getFirstRevision(), MergeHistoryPager\getQueryInfo(), ContribsPager\getQueryInfo(), HistoryPager\getQueryInfo(), Linker\getRollbackEditCount(), RebuildTextIndex\populateSearchIndex(), ApiQueryContributions\prepareQuery(), ApiQueryAllRevisions\run(), CategoryMembershipChangeJob\run(), ApiQueryRevisions\run(), RevisionTest\testGetQueryInfo(), ActorMigrationTest\testInsertUserIdentity(), RevisionDbTestBase\testNewFromRow(), PageArchiveTest\testUndeleteRevisions(), ImportTest\testUnknownUserHandling(), and RevisionDbTestBase\testUserWasLastToEdit().

Revision::getRecentChange (   $flags = 0)

Get the RC object belonging to the current revision, if there's one.

Parameters
int$flags(optional) $flags include: Revision::READ_LATEST : Select the data from the master
Since
1.22
Returns
RecentChange|null

Definition at line 859 of file Revision.php.

static Revision::getRevisionFactory ( )
staticprotected
Returns
RevisionFactory

Definition at line 78 of file Revision.php.

static Revision::getRevisionLookup ( )
staticprotected
Returns
RevisionLookup

Definition at line 71 of file Revision.php.

Revision::getRevisionRecord ( )
Returns
RevisionRecord

Definition at line 608 of file Revision.php.

References $mRecord.

static Revision::getRevisionStore ( )
staticprotected
Returns
RevisionStore

Definition at line 64 of file Revision.php.

static Revision::getRevisionText (   $row,
  $prefix = 'old_',
  $wiki = false 
)
static

Get revision text associated with an old or archive row.

Both the flags and the text field must be included. Including the old_id field will activate cache usage as long as the $wiki parameter is not set.

Parameters
stdClass$rowThe text data
string$prefixTable prefix (default 'old_')
string | bool$wikiThe name of the wiki to load the revision text from (same as the the wiki $row was loaded from) or false to indicate the local wiki (this is the default). Otherwise, it must be a symbolic wiki database identifier as understood by the LoadBalancer class.
Returns
string|false Text the text requested or false on failure

Definition at line 1021 of file Revision.php.

Referenced by CompressOld\compressWithConcat(), MigrateArchiveText\doDBUpdates(), FetchText\doGetText(), RecompressTracked\doOrphanList(), RecompressTracked\doPage(), ApiQueryDeletedrevs\execute(), PageArchive\getLastRevisionText(), TextPassDumper\getTextDb(), PageArchive\getTextFromRow(), MessageCache\loadFromDB(), RevisionTest\testCompressRevisionTextUtf8(), RevisionTest\testCompressRevisionTextUtf8Gzip(), RevisionTest\testGetRevisionText(), RevisionTest\testGetRevisionText_external_noOldId(), RevisionTest\testGetRevisionText_external_oldId(), RevisionTest\testGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts(), RevisionTest\testGetRevisionText_returnsDecompressedTextFieldWhenNotExternal(), RevisionTest\testGetRevisionText_returnsFalseWhenNoTextField(), and XmlDumpWriter\writeRevision().

Revision::getSerializedData ( )

Get original serialized data (without checking view restrictions)

Since
1.21
Deprecated:
since 1.31, use BlobStore::getBlob instead.
Returns
string

Definition at line 918 of file Revision.php.

References getMainSlotRaw().

Revision::getSha1 ( )
Revision::getSize ( )

Returns the length of the text in this revision, or null if unknown.

Returns
int|null

Definition at line 705 of file Revision.php.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), ApiQueryRevisionsBase\extractRevisionInfo(), and MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow().

Revision::getTextId ( )

Get the ID of the row of the text table that contains the content of the revision's main slot, if that content is stored in the text table.

If the content is stored elsewhere, this returns null.

Deprecated:
since 1.31, use RevisionRecord()->getSlot()->getContentAddress() to get that actual address that can be used with BlobStore::getBlob(); or use RevisionRecord::hasSameContent() to check if two revisions have the same content.
Returns
int|null

Definition at line 683 of file Revision.php.

References getMainSlotRaw().

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow().

static Revision::getTimestampFromId (   $title,
  $id,
  $flags = 0 
)
static

Get rev_timestamp from rev_id, without loading the rest of the row.

Parameters
Title$title
int$id
int$flags
Returns
string|bool False if not found

Definition at line 1193 of file Revision.php.

References $title.

Referenced by ApiSetNotificationTimestamp\execute(), and Skin\lastModified().

Revision::getTitle ( )

Returns the title of the page associated with this entry.

Since 1.31, this will never return null.

Will do a query, when title is not set and id is given.

Returns
Title

Definition at line 734 of file Revision.php.

References Title\newFromLinkTarget().

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), ApiQueryRevisionsBase\extractRevisionInfo(), getNext(), getPrevious(), DifferenceEngine\getRevisionHeader(), Linker\revComment(), MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow(), and BenchmarkParse\runParser().

Revision::getUser (   $audience = self::FOR_PUBLIC,
User  $user = null 
)

Fetch revision's user id if it's available to the specified audience.

If the specified audience does not have access to it, zero will be returned.

Parameters
int$audienceOne of: Revision::FOR_PUBLIC to be displayed to all users Revision::FOR_THIS_USER to be displayed to the given user Revision::RAW get the ID regardless of permissions
User | null$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
int

Definition at line 778 of file Revision.php.

References $user, and global.

Referenced by RevisionDbTestBase\assertRevEquals(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), ApiQueryRevisionsBase\extractRevisionInfo(), and MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow().

Revision::getUserText (   $audience = self::FOR_PUBLIC,
User  $user = null 
)

Fetch revision's username if it's available to the specified audience.

If the specified audience does not have access to the username, an empty string will be returned.

Parameters
int$audienceOne of: Revision::FOR_PUBLIC to be displayed to all users Revision::FOR_THIS_USER to be displayed to the given user Revision::RAW get the text regardless of permissions
User | null$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
string

Definition at line 802 of file Revision.php.

References $user, and global.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), ApiQueryRevisionsBase\extractRevisionInfo(), and MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow().

Revision::getVisibility ( )
Revision::insertOn (   $dbw)

Insert a new revision into the database, returning the new revision ID number on success and dies horribly on failure.

Parameters
IDatabase$dbw(master connection)
Exceptions
MWException
Returns
int The revision ID

Definition at line 1077 of file Revision.php.

References global, and Hooks\run().

Revision::isCurrent ( )
Returns
bool

Definition at line 981 of file Revision.php.

Referenced by DifferenceEngine\getRevisionHeader().

Revision::isDeleted (   $field)
Parameters
int$fieldOne of DELETED_* bitfield constants
Returns
bool

Definition at line 868 of file Revision.php.

Referenced by ApiQueryRevisionsBase\extractRevisionInfo(), Linker\getRevDeleteLink(), DifferenceEngine\getRevisionHeader(), and Linker\revComment().

Revision::isUnpatrolled ( )
Returns
int Rcid of the unpatrolled row, zero if there isn't one

Definition at line 846 of file Revision.php.

static Revision::loadFromId (   $db,
  $id 
)
static

Load a page revision from a given revision ID number.

Returns null if no such revision can be found.

Deprecated:
since 1.31, use RevisionStore::getRevisionById() instead.
Parameters
IDatabase$db
int$id
Returns
Revision|null

Definition at line 238 of file Revision.php.

References wfDeprecated().

Referenced by RevisionDbTestBase\testLoadFromId().

static Revision::loadFromPageId (   $db,
  $pageid,
  $id = 0 
)
static

Load either the current, or a specified, revision that's attached to a given page.

If not attached to that page, will return null.

Deprecated:
since 1.31, use RevisionStore::getRevisionByPageId() instead.
Parameters
IDatabase$db
int$pageid
int$id
Returns
Revision|null

Definition at line 256 of file Revision.php.

Referenced by RevisionDbTestBase\testLoadFromPageId(), RevisionDbTestBase\testLoadFromPageIdWithLatestRevId(), RevisionDbTestBase\testLoadFromPageIdWithNotLatestRevId(), and Maintenance\updateSearchIndexForPage().

static Revision::loadFromTimestamp (   $db,
  $title,
  $timestamp 
)
static

Load the revision for the given title with the given timestamp.

WARNING: Timestamps may in some circumstances not be unique, so this isn't the best key to use.

Deprecated:
since 1.31, use RevisionStore::getRevisionByTimestamp() or RevisionStore::loadRevisionFromTimestamp() instead.
Parameters
IDatabase$db
Title$title
string$timestamp
Returns
Revision|null

Definition at line 291 of file Revision.php.

References $title.

Referenced by AttachLatest\execute(), EditPage\getBaseRevision(), User\getNewMessageLinks(), WikiPage\replaceSectionContent(), and RevisionDbTestBase\testLoadFromTimestamp().

static Revision::loadFromTitle (   $db,
  $title,
  $id = 0 
)
static

Load either the current, or a specified, revision that's attached to a given page.

If not attached to that page, will return null.

Deprecated:
since 1.31, use RevisionStore::getRevisionByTitle() instead.
Parameters
IDatabase$db
Title$title
int$id
Returns
Revision|null

Definition at line 273 of file Revision.php.

References $title.

Referenced by EditPage\mergeChangesIntoContent(), RevisionTest\testLoadFromTitle(), RevisionDbTestBase\testLoadFromTitle(), RevisionDbTestBase\testLoadFromTitleWithLatestRevId(), and RevisionDbTestBase\testLoadFromTitleWithNotLatestRevId().

static Revision::newFromId (   $id,
  $flags = 0 
)
static

Load a page revision from a given revision ID number.

Returns null if no such revision can be found.

$flags include: Revision::READ_LATEST : Select the data from the master Revision::READ_LOCKING : Select & lock the data from the master

Parameters
int$id
int$flags(optional)
Returns
Revision|null

Definition at line 114 of file Revision.php.

Referenced by SpecialComparePages\checkExistingRevision(), Orphans\checkSeparation(), User\clearNotification(), WikiPage\commitRollback(), EditPage\edit(), ApiComparePages\execute(), ApiExpandTemplates\execute(), ApiEditPage\execute(), ApiPatrol\execute(), CheckBadRedirects\execute(), ApiParse\execute(), ImportTextFiles\execute(), BenchmarkParse\execute(), SpecialNewpages\feedItemDesc(), Article\fetchContentObject(), FeedUtils\formatDiffRow(), EditPage\getBaseRevision(), EditPage\getContentObject(), ApiComparePages\getDiffContent(), Article\getOldIDFromRequest(), PageArchive\getPreviousRevision(), CategoryMembershipChange\getPreviousRevisionTimestamp(), Parser\getRevisionObject(), ApiComparePages\guessTitleAndModel(), DifferenceEngine\loadRevisionData(), CategoryMembershipChangeJob\notifyUpdatesForRevision(), ApiQueryRevisionsBase\parseParameters(), MediaWiki\parseTitle(), WikiPage\prepareContentForEdit(), ApiTag\processIndividual(), WikiPage\replaceSectionAtRev(), ApiTestCase\revisionDelete(), RefreshLinksJob\runForTitle(), Article\setOldSubtitle(), SpecialComparePages\showDiff(), Parser\statelessFetchTemplate(), RevDelRevisionList\suggestTarget(), CategoryMembershipChangeTest\testChangeAddedWithRev(), CategoryMembershipChangeTest\testChangeRemovedWithRev(), RevisionDbTestBase\testGetPage(), ApiRevisionDeleteTest\testHidingRevisions(), RevisionDbTestBase\testIsCurrent(), RevisionDbTestBase\testNewFromId(), and ChangeTags\updateTagsWithChecks().

static Revision::newFromPageId (   $pageId,
  $revId = 0,
  $flags = 0 
)
static

Load either the current, or a specified, revision that's attached to a given page ID.

Returns null if no such revision can be found.

$flags include: Revision::READ_LATEST : Select the data from the master (since 1.20) Revision::READ_LOCKING : Select & lock the data from the master

Parameters
int$pageId
int$revId(optional)
int$flagsBitfield (optional)
Returns
Revision|null

Definition at line 152 of file Revision.php.

Referenced by NamespaceConflictChecker\canMerge(), ApiStashEdit\execute(), WikiPage\loadLastEdit(), RevisionDbTestBase\testNewFromPageId(), RevisionDbTestBase\testNewFromPageIdWithLatestId(), and RevisionDbTestBase\testNewFromPageIdWithNotLatestId().

static Revision::newFromRow (   $row)
static
Since
1.19

MCR migration note: replaced by RevisionStore::newRevisionFromRow(). Note that newFromRow() also accepts arrays, while newRevisionFromRow() does not. Instead, a MutableRevisionRecord should be constructed directly. RevisionStore::newMutableRevisionFromArray() can be used as a temporary replacement, but should be avoided.

Parameters
object | array$row
Returns
Revision

Definition at line 218 of file Revision.php.

Referenced by ApiFeedContributions\feedItem(), ApiQueryAllRevisions\run(), CategoryMembershipChangeJob\run(), and RevisionDbTestBase\testNewFromRow().

static Revision::newFromTitle ( LinkTarget  $linkTarget,
  $id = 0,
  $flags = 0 
)
static
static Revision::newKnownCurrent ( IDatabase  $db,
  $pageIdOrTitle,
  $revId = 0 
)
static

Load a revision based on a known page ID and current revision ID from the DB.

This method allows for the use of caching, though accessing anything that normally requires permission checks (aside from the text) will trigger a small DB lookup. The title will also be loaded if $pageIdOrTitle is an integer ID.

Parameters
IDatabase$dbignored!
int | Title$pageIdOrTitlePage ID or Title object
int$revIdKnown current revision of this page. Determined automatically if not given.
Returns
Revision|bool Returns false if missing
Since
1.28

Definition at line 1256 of file Revision.php.

References $title, and Title\newFromID().

Referenced by ResourceLoaderWikiModule\getContentObj(), MessageCache\getMsgFromNamespace(), WikiPage\loadLastEdit(), Parser\statelessFetchRevision(), RevisionDbTestBase\testNewKnownCurrent(), RevisionDbTestBase\testNewKnownCurrent_returnsFalseWhenTitleDoesntExist(), and RevisionDbTestBase\testNewKnownCurrent_withPageId().

static Revision::newNullRevision (   $dbw,
  $pageId,
  $summary,
  $minor,
  $user = null 
)
static

Create a new null-revision for insertion into a page's history.

This will not re-save the text, but simply refer to the text from the previous version.

Such revisions can for instance identify page rename operations and other such meta-modifications.

Parameters
IDatabase$dbw
int$pageIdID number of the page to read from
string$summaryRevision's summary
bool$minorWhether the revision should be considered as minor
User | null$userUser object to use or null for $wgUser
Returns
Revision|null Revision or null on error

Definition at line 1127 of file Revision.php.

References $title, $user, Title\GAID_FOR_UPDATE, global, Title\newFromID(), and CommentStoreComment\newUnsavedComment().

Referenced by WikiPage\insertProtectNullRevision(), MovePage\moveToInternal(), LocalFile\recordUpload2(), ImportReporter\reportPage(), RevisionDbTestBase\testNewNullRevision(), and RevisionDbTestBase\testNewNullRevision_badPage().

static Revision::pageJoinCond ( )
static

Return the value of a select() page conds array for the page table.

This will assure that the revision(s) are not orphaned from live pages.

Since
1.19
Deprecated:
since 1.31, use RevisionStore::getQueryInfo( [ 'page' ] ) instead.
Returns
array

Definition at line 340 of file Revision.php.

References wfDeprecated().

Referenced by RevisionTest\testPageJoinCond().

static Revision::selectArchiveFields ( )
static

Return the list of revision fields that should be selected to create a new revision from an archive row.

Deprecated:
since 1.31, use RevisionStore::getArchiveQueryInfo() instead.
Returns
array

Definition at line 397 of file Revision.php.

References CommentStore\getStore(), global, MIGRATION_WRITE_BOTH, and wfDeprecated().

Referenced by RevisionTest\testSelectArchiveFields().

static Revision::selectFields ( )
static

Return the list of revision fields that should be selected to create a new revision.

Deprecated:
since 1.31, use RevisionStore::getQueryInfo() instead.
Returns
array

Definition at line 351 of file Revision.php.

References CommentStore\getStore(), global, MIGRATION_WRITE_BOTH, and wfDeprecated().

Referenced by RevisionTest\testSelectFields().

static Revision::selectPageFields ( )
static

Return the list of page fields that should be selected from page table.

Deprecated:
since 1.31, use RevisionStore::getQueryInfo( [ 'page' ] ) instead.
Returns
array

Definition at line 456 of file Revision.php.

References wfDeprecated().

Referenced by RevisionTest\testSelectPageFields().

static Revision::selectTextFields ( )
static

Return the list of text fields that should be selected to read the revision text.

Deprecated:
since 1.31, use RevisionStore::getQueryInfo( [ 'text' ] ) instead.
Returns
array

Definition at line 443 of file Revision.php.

References wfDeprecated().

Referenced by RevisionTest\testSelectTextFields().

static Revision::selectUserFields ( )
static

Return the list of user fields that should be selected from user table.

Deprecated:
since 1.31, use RevisionStore::getQueryInfo( [ 'user' ] ) instead.
Returns
array

Definition at line 473 of file Revision.php.

References wfDeprecated().

Referenced by RevisionTest\testSelectUserFields().

Revision::setId (   $id)

Set the revision ID.

This should only be used for proposed revisions that turn out to be null edits.

Note
Only supported on Revisions that were constructed based on associative arrays, since they are mutable.
Since
1.19
Parameters
int | string$id
Exceptions
MWException

Definition at line 633 of file Revision.php.

Revision::setTitle (   $title)

Set the title of the revision.

Deprecated:
: since 1.31, this is now a noop. Pass the Title to the constructor instead.
Parameters
Title$title

Definition at line 746 of file Revision.php.

References $title.

Revision::setUserIdAndName (   $id,
  $name 
)

Set the user ID/name.

This should only be used for proposed revisions that turn out to be null edits

Note
Only supported on Revisions that were constructed based on associative arrays, since they are mutable.
Since
1.28
Deprecated:
since 1.31, please reuse old Revision object
Parameters
int$idUser ID
string$nameUser name
Exceptions
MWException

Definition at line 655 of file Revision.php.

References $name, $user, and User\newFromAnyId().

Revision::userCan (   $field,
User  $user = null 
)

Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted.

Parameters
int$fieldOne of self::DELETED_TEXT, self::DELETED_COMMENT, self::DELETED_USER
User | null$userUser object to check, or null to use $wgUser
Returns
bool

Definition at line 1155 of file Revision.php.

References $user, and getVisibility().

Referenced by ApiQueryRevisionsBase\extractRevisionInfo(), Linker\getRevDeleteLink(), DifferenceEngine\getRevisionHeader(), and Linker\revComment().

static Revision::userCanBitfield (   $bitfield,
  $field,
User  $user = null,
Title  $title = null 
)
static

Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted.

This is used by various classes to avoid duplication.

Parameters
int$bitfieldCurrent field
int$fieldOne of self::DELETED_TEXT = File::DELETED_FILE, self::DELETED_COMMENT = File::DELETED_COMMENT, self::DELETED_USER = File::DELETED_USER
User | null$userUser object to check, or null to use $wgUser
Title | null$titleA Title object to check for per-page restrictions on, instead of just plain userrights
Returns
bool

Definition at line 1173 of file Revision.php.

References $title, $user, and global.

Referenced by ApiQueryDeletedrevs\execute(), ApiQueryFilearchive\execute(), ApiQueryWatchlist\extractOutputData(), ApiQueryRecentChanges\extractRowInfo(), ApiQueryContributions\extractRowInfo(), RevisionDbTestBase\testUserCanBitfield(), OldLocalFile\userCan(), ChangesList\userCan(), and ArchivedFile\userCan().

static Revision::userJoinCond ( )
static

Return the value of a select() JOIN conds array for the user table.

This will get user table rows for logged-in users.

Since
1.19
Deprecated:
since 1.31, use RevisionStore::getQueryInfo( [ 'user' ] ) instead.
Returns
array

Definition at line 317 of file Revision.php.

References global, MIGRATION_WRITE_BOTH, and wfDeprecated().

Referenced by RevisionTest\testUserJoinCond().

static Revision::userWasLastToEdit (   $db,
  $pageId,
  $userId,
  $since 
)
static

Check if no edits were made by other users since the time a user started editing the page.

Limit to 50 revisions for the sake of performance.

Since
1.20
Deprecated:
since 1.24
Parameters
IDatabase | int$dbThe Database to perform the check on. May be given as a Database object or a database identifier usable with wfGetDB.
int$pageIdThe ID of the page in question
int$userIdThe ID of the user in question
string$sinceLook at edits since this time
Returns
bool True if the given user was the only one to edit since the given timestamp

Definition at line 1235 of file Revision.php.

References wfGetDB().

Referenced by EditPage\internalAttemptSave(), and RevisionDbTestBase\testUserWasLastToEdit().

Member Data Documentation

RevisionRecord Revision::$mRecord
protected

Definition at line 44 of file Revision.php.

Referenced by getRevisionRecord().

const Revision::DELETED_RESTRICTED = RevisionRecord::DELETED_RESTRICTED
const Revision::DELETED_TEXT = RevisionRecord::DELETED_TEXT

Definition at line 47 of file Revision.php.

Referenced by ApiParseTest\addDBDataOnce(), ApiComparePagesTest\addDBDataOnce(), RevDelRevisionItem\canViewContent(), RevisionItem\canViewContent(), CleanupSpam\cleanupArticle(), WikiPage\commitRollback(), HistoryPager\curLink(), HistoryPager\diffButtons(), ApiEditPage\execute(), ApiQueryDeletedrevs\execute(), ApiParse\execute(), ApiQueryRevisionsBase\extractRevisionInfo(), ApiQueryRecentChanges\extractRowInfo(), ApiQueryContributions\extractRowInfo(), DeletedContribsPager\formatRevisionRow(), SpecialMergeHistory\formatRevisionRow(), SpecialUndelete\formatRevisionRow(), ContribsPager\formatRow(), RevDelRevisionItem\getApiData(), ChangesList\getArticleLink(), RevisionDeleter\getChanges(), EditPage\getContentObject(), DifferenceEngine\getDiffBody(), EnhancedChangesList\getLineData(), EnhancedChangesList\getLogText(), SpecialUndelete\getPageLink(), DeleteLogFormatter\getParametersForApi(), ApiParse\getParsedContent(), RevDelRevisionList\getRevdelConstant(), DifferenceEngine\getRevisionHeader(), Linker\getRollbackEditCount(), HistoryPager\historyLine(), ChangesList\insertDiffHist(), RevDelRevisionItem\isDeleted(), RevisionItem\isDeleted(), RevDelRevisionItem\isHideCurrentOp(), HistoryPager\lastLink(), ApiQueryRevisionsBase\parseParameters(), RevisionTest\provideConstructFromRow(), RevisionDbTestBase\provideUserCan(), RevisionDbTestBase\provideUserCanBitfield(), HistoryPager\revLink(), ApiComparePages\setVals(), Article\showDeletedRevisionHeader(), RCCacheEntryFactory\showDiffLinks(), DifferenceEngine\showDiffPage(), EditPage\showHeader(), SpecialUndelete\showRevision(), RevisionDbTestBase\testIsDeleted_nothingDeleted(), ApiEditPageTest\testUndoAfterToHiddenRev(), PageArchive\undeleteRevisions(), and XmlDumpWriter\writeRevision().

const Revision::DELETED_USER = RevisionRecord::DELETED_USER

Definition at line 49 of file Revision.php.

Referenced by ApiComparePagesTest\addDBDataOnce(), ChangesFeed\buildItems(), WikiPage\commitRollback(), WikiExporter\do_list_authors(), ApiRevisionDelete\execute(), ApiQueryDeletedrevs\execute(), ApiQueryContributors\execute(), SpecialRevisionDelete\execute(), ApiQueryWatchlist\extractOutputData(), ApiQueryRevisionsBase\extractRevisionInfo(), ApiQueryRecentChanges\extractRowInfo(), ApiQueryContributions\extractRowInfo(), DeletedContribsPager\formatRevisionRow(), ContribsPager\formatRow(), RevDelArchivedFileItem\getApiData(), RevDelRevisionItem\getApiData(), RevDelFileItem\getApiData(), ContentHandler\getAutoDeleteReason(), RevisionDeleter\getChanges(), DeleteLogFormatter\getParametersForApi(), DeletedContribsPager\getQueryInfo(), ContribsPager\getQueryInfo(), Linker\getRollbackEditCount(), RCCacheEntryFactory\getUserLink(), WatchedItemQueryService\getUserRelatedConds(), RevDelFileItem\getUserTools(), ChangesList\insertUserRelatedLinks(), RCCacheEntryFactory\newFromRecentChange(), ApiQueryContributions\prepareQuery(), RevisionDbTestBase\provideUserCan(), RevisionDbTestBase\provideUserCanBitfield(), Linker\revUserLink(), Linker\revUserTools(), ApiQueryDeletedRevisions\run(), ApiQueryAllRevisions\run(), ApiQueryAllDeletedRevisions\run(), ApiQueryRevisions\run(), ApiQueryRecentChanges\run(), RevisionDeleteUser\setUsernameBitfields(), ApiComparePages\setVals(), RevisionDbTestBase\testIsDeleted_nothingDeleted(), WatchedItemQueryServiceUnitTest\userPermissionRelatedExtraChecksProvider(), and XmlDumpWriter\writeRevision().

const Revision::SUPPRESSED_ALL = RevisionRecord::SUPPRESSED_ALL

Definition at line 52 of file Revision.php.

Referenced by LocalFileDeleteBatch\doDBInserts(), and WikiPage\doDeleteArticleReal().

const Revision::SUPPRESSED_USER = RevisionRecord::SUPPRESSED_USER
const Revision::TEXT_CACHE_GROUP = SqlBlobStore::TEXT_CACHE_GROUP

Definition at line 59 of file Revision.php.


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