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

Public Member Functions

 __construct ( $row)
 Constructor.
 
 getComment ( $audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision comment if it's available to the specified audience.
 
 getContent ( $audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision content if it's available to the specified audience.
 
 getContentFormat ()
 Returns the content format for this revision.
 
 getContentHandler ()
 Returns the content handler appropriate for this revision's content model.
 
 getContentModel ()
 Returns the content model for this revision.
 
 getId ()
 Get revision ID.
 
 getNext ()
 Get next revision for this title.
 
 getPage ()
 Get the page ID.
 
 getParentId ()
 Get parent revision ID (the original previous page revision)
 
 getPrevious ()
 Get previous revision for this title.
 
 getRawComment ()
 Fetch revision comment without regard for the current user's permissions.
 
 getRawUser ()
 Fetch revision's user id without regard for the current user's permissions.
 
 getRawUserText ()
 Fetch revision's username without regard for view restrictions.
 
 getRecentChange ( $flags=0)
 Get the RC object belonging to the current revision, if there's one.
 
 getSerializedData ()
 Fetch original serialized data without regard for view restrictions.
 
 getSha1 ()
 Returns the base36 sha1 of the text in this revision, or null if unknown.
 
 getSize ()
 Returns the length of the text in this revision, or null if unknown.
 
 getText ( $audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision text if it's available to the specified audience.
 
 getTextId ()
 Get text row ID.
 
 getTimestamp ()
 
 getTitle ()
 Returns the title of the page associated with this entry or null.
 
 getUser ( $audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision's user id if it's available to the specified audience.
 
 getUserText ( $audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision's username if it's available to the specified audience.
 
 getVisibility ()
 Get the deletion bitfield of the revision.
 
 insertOn ( $dbw)
 Insert a new revision into the database, returning the new revision ID number on success and dies horribly on failure.
 
 isCurrent ()
 
 isDeleted ( $field)
 
 isMinor ()
 
 isUnpatrolled ()
 
 setId ( $id)
 Set the revision ID.
 
 setTitle ( $title)
 Set the title of the 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.
 

Static Public Member Functions

static base36Sha1 ( $text)
 Get the base 36 SHA-1 value for a string of text.
 
static compressRevisionText (&$text)
 If $wgCompressRevisions is enabled, we will compress data.
 
static countByPageId ( $db, $id)
 Get count of revisions per page...not very efficient.
 
static countByTitle ( $db, $title)
 Get count of revisions per page...not very efficient.
 
static decompressRevisionText ( $text, $flags)
 Re-converts revision text according to it's flags.
 
static fetchRevision ( $title)
 Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn.
 
static getParentLengths ( $db, array $revIds)
 Do a batched query to get the parent revision lengths.
 
static getRevisionText ( $row, $prefix='old_', $wiki=false)
 Get revision text associated with an old or archive row $row is usually an object from wfFetchRow(), both the flags and the text field must be included.
 
static getTimestampFromId ( $title, $id, $flags=0)
 Get rev_timestamp from rev_id, without loading the rest of the row.
 
static loadFromId ( $db, $id)
 Load a page revision from a given revision ID number.
 
static loadFromPageId ( $db, $pageid, $id=0)
 Load either the current, or a specified, revision that's attached to a given page.
 
static loadFromTimestamp ( $db, $title, $timestamp)
 Load the revision for the given title with the given timestamp.
 
static loadFromTitle ( $db, $title, $id=0)
 Load either the current, or a specified, revision that's attached to a given page.
 
static newFromArchiveRow ( $row, $overrides=[])
 Make a fake revision object from an archive table row.
 
static newFromId ( $id, $flags=0)
 Load a page revision from a given revision ID number.
 
static newFromPageId ( $pageId, $revId=0, $flags=0)
 Load either the current, or a specified, revision that's attached to a given page ID.
 
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.
 
static newNullRevision ( $dbw, $pageId, $summary, $minor, $user=null)
 Create a new null-revision for insertion into a page's history.
 
static pageJoinCond ()
 Return the value of a select() page conds array for the page table.
 
static selectArchiveFields ()
 Return the list of revision fields that should be selected to create a new revision from an archive row.
 
static selectFields ()
 Return the list of revision fields that should be selected to create a new revision.
 
static selectPageFields ()
 Return the list of page fields that should be selected from page table.
 
static selectTextFields ()
 Return the list of text fields that should be selected to read the revision text.
 
static selectUserFields ()
 Return the list of user fields that should be selected from user table.
 
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.
 
static userJoinCond ()
 Return the value of a select() JOIN conds array for the user table.
 
static userWasLastToEdit ( $db, $pageId, $userId, $since)
 Check if no edits were made by other users since the time a user started editing the page.
 

Public Attributes

const DELETED_COMMENT = 2
 
const DELETED_RESTRICTED = 8
 
const DELETED_TEXT = 1
 
const DELETED_USER = 4
 
const FOR_PUBLIC = 1
 
const FOR_THIS_USER = 2
 
const RAW = 3
 
const SUPPRESSED_USER = 12
 
- Public Attributes inherited from IDBAccessObject
const READ_EXCLUSIVE = 7
 
const READ_LATEST = 1
 
const READ_LOCKING = 3
 
const READ_NONE = -1
 
const READ_NORMAL = 0
 

Protected Member Functions

 checkContentModel ()
 
 getContentInternal ()
 Gets the content object for the revision (or null on failure).
 
 loadText ()
 Lazy-load the revision's text.
 

Protected Attributes

 $mComment
 
Content null bool $mContent
 
 $mContentFormat
 
null ContentHandler $mContentHandler
 
 $mContentModel
 
 $mCurrent
 
 $mDeleted
 
 $mId
 
 $mMinorEdit
 
 $mOrigUserText
 
int null $mPage
 
 $mParentId
 
int $mQueryFlags = 0
 
 $mSha1
 
 $mSize
 
 $mText
 
 $mTextId
 
stdClass null $mTextRow
 
 $mTimestamp
 
null Title $mTitle
 
 $mUser
 
 $mUserText
 

Private Member Functions

 getPreviousRevisionId ( $db)
 Get previous revision Id for this page_id This is used to populate rev_parent_id on save.
 

Static Private Member Functions

static fetchFromConds ( $db, $conditions, $flags=0)
 Given a set of conditions, return a ResultWrapper which will return matching database rows with the fields necessary to build Revision objects.
 
static loadFromConds ( $db, $conditions, $flags=0)
 Given a set of conditions, fetch a revision from the given database connection.
 
static newFromConds ( $conditions, $flags=0)
 Given a set of conditions, fetch a revision.
 

Detailed Description

Todo:
document

Definition at line 27 of file Revision.php.

Constructor & Destructor Documentation

◆ __construct()

Revision::__construct (   $row)

Constructor.

Parameters
object | array$rowEither a database row or an array
Exceptions
MWException
Access:\n private

Definition at line 549 of file Revision.php.

References $handler, $wgUser, base36Sha1(), getContentFormat(), getContentHandler(), getContentModel(), global, needed(), Title\newFromRow(), on, wfDebug(), and wfTimestampNow().

Member Function Documentation

◆ base36Sha1()

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 1529 of file Revision.php.

Referenced by __construct(), RevisionTest\dataGetSha1(), insertOn(), PopulateRevisionSha1\upgradeLegacyArchiveRow(), and PopulateRevisionSha1\upgradeRow().

◆ checkContentModel()

◆ compressRevisionText()

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 1276 of file Revision.php.

References $flags, $wgCompressRevisions, global, wfDebug(), and wfLogWarning().

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

◆ countByPageId()

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 1775 of file Revision.php.

Referenced by countByTitle().

◆ countByTitle()

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 1791 of file Revision.php.

References $title, and countByPageId().

◆ decompressRevisionText()

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 1308 of file Revision.php.

References $flags, $wgContLang, $wgLegacyEncoding, global, unserialize(), and wfLogWarning().

Referenced by getRevisionText().

◆ fetchFromConds()

static Revision::fetchFromConds (   $db,
  $conditions,
  $flags = 0 
)
staticprivate

Given a set of conditions, return a ResultWrapper which will return matching database rows with the fields necessary to build Revision objects.

Parameters
IDatabase$db
array$conditions
int$flags(optional)
Returns
ResultWrapper

Definition at line 384 of file Revision.php.

References $flags, and $options.

Referenced by fetchRevision(), and loadFromConds().

◆ fetchRevision()

static Revision::fetchRevision (   $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
Title$title
Returns
ResultWrapper

Definition at line 363 of file Revision.php.

References $title, DB_SLAVE, fetchFromConds(), and wfGetDB().

Referenced by RevisionStorageTest\testFetchRevision().

◆ getComment()

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$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
string

Definition at line 905 of file Revision.php.

References $mComment, $user, isDeleted(), and userCan().

Referenced by ApiQueryRevisionsBase\extractRevisionInfo(), and getRawComment().

◆ getContent()

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, 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 $wgUser 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 1029 of file Revision.php.

References $user, getContentInternal(), isDeleted(), and userCan().

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

◆ getContentFormat()

Revision::getContentFormat ( )

Returns the content format for this revision.

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

Returns
string The content format id associated with this revision, see the CONTENT_FORMAT_XXX constants.

Definition at line 1116 of file Revision.php.

References $handler, $mContentFormat, and getContentHandler().

Referenced by __construct(), RevisionStorageTest\assertRevEquals(), checkContentModel(), getContentHandler(), getContentInternal(), and insertOn().

◆ getContentHandler()

Revision::getContentHandler ( )

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

Exceptions
MWException
Returns
ContentHandler

Definition at line 1133 of file Revision.php.

References $mContentHandler, getContentFormat(), getContentModel(), and ContentHandler\getForModelID().

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

◆ getContentInternal()

Revision::getContentInternal ( )
protected

Gets the content object for the revision (or null on failure).

Note that for mutable Content objects, each call to this method will return a fresh clone.

Since
1.21
Returns
Content|null The Revision's content, or null on failure.

Definition at line 1062 of file Revision.php.

References $handler, getContentFormat(), getContentHandler(), and loadText().

Referenced by getContent().

◆ getContentModel()

Revision::getContentModel ( )

Returns the content model for 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.

Returns
string The content model id associated with this revision, see the CONTENT_MODEL_XXX constants.

Definition at line 1092 of file Revision.php.

References $mContentModel, $title, CONTENT_MODEL_WIKITEXT, ContentHandler\getDefaultModelFor(), and getTitle().

Referenced by __construct(), RevisionStorageTest\assertRevEquals(), checkContentModel(), ApiQueryRevisionsBase\extractRevisionInfo(), getContentHandler(), and insertOn().

◆ getId()

◆ getNext()

Revision::getNext ( )

Get next revision for this title.

Returns
Revision|null

Definition at line 1183 of file Revision.php.

References getId(), getTitle(), and newFromTitle().

◆ getPage()

Revision::getPage ( )

Get the page ID.

Returns
int|null

Definition at line 812 of file Revision.php.

References $mPage.

Referenced by RevisionStorageTest\assertRevEquals().

◆ getParentId()

Revision::getParentId ( )

Get parent revision ID (the original previous page revision)

Returns
int|null

Definition at line 744 of file Revision.php.

References $mParentId.

Referenced by ApiQueryRevisionsBase\extractRevisionInfo(), and CategoryMembershipChangeJob\notifyUpdatesForRevision().

◆ getParentLengths()

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

Do a batched query to get the parent revision lengths.

Parameters
IDatabase$db
array$revIds
Returns
array

Definition at line 527 of file Revision.php.

References $res, and as.

Referenced by HistoryPager\doBatchLookups(), ContribsPager\doBatchLookups(), and ApiQueryContributions\execute().

◆ getPrevious()

Revision::getPrevious ( )

Get previous revision for this title.

Returns
Revision|null

Definition at line 1168 of file Revision.php.

References getId(), getTitle(), and newFromTitle().

◆ getPreviousRevisionId()

Revision::getPreviousRevisionId (   $db)
private

Get previous revision Id for this page_id This is used to populate rev_parent_id on save.

Parameters
IDatabase$db
Returns
int

Definition at line 1200 of file Revision.php.

Referenced by insertOn().

◆ getRawComment()

Revision::getRawComment ( )

Fetch revision comment without regard for the current user's permissions.

Returns
string
Deprecated:
since 1.25, use getComment( Revision::RAW )

Definition at line 921 of file Revision.php.

References getComment(), and wfDeprecated().

◆ getRawUser()

Revision::getRawUser ( )

Fetch revision's user id without regard for the current user's permissions.

Returns
string
Deprecated:
since 1.25, use getUser( Revision::RAW )

Definition at line 845 of file Revision.php.

References getUser(), and wfDeprecated().

◆ getRawUserText()

Revision::getRawUserText ( )

Fetch revision's username without regard for view restrictions.

Returns
string
Deprecated:
since 1.25, use getUserText( Revision::RAW )

Definition at line 887 of file Revision.php.

References getUserText(), and wfDeprecated().

◆ getRecentChange()

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 958 of file Revision.php.

References $dbr, $flags, DB_SLAVE, DBAccessObjectUtils\getDBOptions(), getUserText(), list, RecentChange\newFromConds(), RAW, and wfGetDB().

Referenced by isUnpatrolled().

◆ getRevisionText()

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

Get revision text associated with an old or archive row $row is usually an object from wfFetchRow(), both the flags and the text field must be included.

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 Text the text requested or false on failure

Definition at line 1231 of file Revision.php.

References $flags, decompressRevisionText(), and ExternalStore\fetchFromURL().

Referenced by CompressOld\compressWithConcat(), FetchText\doGetText(), RecompressTracked\doOrphanList(), RecompressTracked\doPage(), ApiQueryDeletedrevs\execute(), TextPassDumper\getTextDb(), PageArchive\getTextFromRow(), MessageCache\loadFromDB(), loadText(), newFromArchiveRow(), RevisionTest\testCompressRevisionTextUtf8(), RevisionTest\testCompressRevisionTextUtf8Gzip(), RevisionTest\testGetRevisionText(), RevisionTest\testGetRevisionTextGzip(), RevisionTest\testGetRevisionTextUtf8Legacy(), RevisionTest\testGetRevisionTextUtf8LegacyGzip(), RevisionTest\testGetRevisionTextUtf8Native(), RevisionTest\testGetRevisionTextUtf8NativeGzip(), and XmlDumpWriter\writeRevision().

◆ getSerializedData()

Revision::getSerializedData ( )

Fetch original serialized data without regard for view restrictions.

Since
1.21
Returns
string

Definition at line 1045 of file Revision.php.

References $mText, and loadText().

◆ getSha1()

Revision::getSha1 ( )

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

Returns
string|null

Definition at line 762 of file Revision.php.

References $mSha1.

Referenced by RevisionStorageTest\assertRevEquals(), and ApiQueryRevisionsBase\extractRevisionInfo().

◆ getSize()

Revision::getSize ( )

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

Returns
int|null

Definition at line 753 of file Revision.php.

References $mSize.

Referenced by ApiQueryRevisionsBase\extractRevisionInfo().

◆ getText()

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

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

If the specified audience does not have the ability to view this revision, 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$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Deprecated:
since 1.21, use getContent() instead
Todo:
Replace usage in core
Returns
string

Definition at line 1008 of file Revision.php.

References $content, $user, content, ContentHandler\deprecated(), getContent(), ContentHandler\getContentText(), text, and the.

◆ getTextId()

Revision::getTextId ( )

Get text row ID.

Returns
int|null

Definition at line 735 of file Revision.php.

References $mTextId.

Referenced by loadText().

◆ getTimestamp()

◆ getTimestampFromId()

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
Returns
string|bool False if not found

Definition at line 1753 of file Revision.php.

References $flags, $timestamp, $title, DB_MASTER, DB_SLAVE, IDBAccessObject\READ_LATEST, TS_MW, wfGetDB(), and wfTimestamp().

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

◆ getTitle()

Revision::getTitle ( )

Returns the title of the page associated with this entry or null.

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

Returns
Title|null

Definition at line 773 of file Revision.php.

References $dbr, $mTitle, DB_SLAVE, Title\newFromID(), Title\newFromRow(), and wfGetDB().

Referenced by checkContentModel(), ApiQueryRevisionsBase\extractRevisionInfo(), getContentModel(), getNext(), getPrevious(), insertOn(), and BenchmarkParse\runParser().

◆ getUser()

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$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
int

Definition at line 829 of file Revision.php.

References $mUser, $user, isDeleted(), and userCan().

Referenced by RevisionStorageTest\assertRevEquals(), ApiQueryRevisionsBase\extractRevisionInfo(), and getRawUser().

◆ getUserText()

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$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
string

Definition at line 863 of file Revision.php.

References $mOrigUserText, $mUserText, $user, isDeleted(), and userCan().

Referenced by ApiQueryRevisionsBase\extractRevisionInfo(), getRawUserText(), and getRecentChange().

◆ getVisibility()

Revision::getVisibility ( )

Get the deletion bitfield of the revision.

Returns
int

Definition at line 988 of file Revision.php.

References $mDeleted.

Referenced by CategoryMembershipChange\notifyCategorization().

◆ insertOn()

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

Definition at line 1354 of file Revision.php.

References $flags, $mComment, $mDeleted, $mId, $mPage, $mParentId, $mSha1, $mSize, $mText, $mTextId, $mUser, $mUserText, $title, $wgContentHandlerUseDB, $wgDefaultExternalStore, base36Sha1(), checkContentModel(), compressRevisionText(), getContentFormat(), getContentModel(), ContentHandler\getDefaultModelFor(), ContentHandler\getForModelID(), getPreviousRevisionId(), getTitle(), global, and ExternalStore\insertToDefault().

Referenced by WikiPage\doQuickEditContent().

◆ isCurrent()

Revision::isCurrent ( )
Returns
bool

Definition at line 1159 of file Revision.php.

References $mCurrent.

Referenced by DifferenceEngine\getParserOutput(), and DifferenceEngine\getRevisionHeader().

◆ isDeleted()

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

Definition at line 979 of file Revision.php.

Referenced by ApiQueryRevisionsBase\extractRevisionInfo(), getComment(), getContent(), getUser(), and getUserText().

◆ isMinor()

Revision::isMinor ( )
Returns
bool

Definition at line 929 of file Revision.php.

References $mMinorEdit.

Referenced by WikiPage\doEditUpdates(), and ApiQueryRevisionsBase\extractRevisionInfo().

◆ isUnpatrolled()

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

Definition at line 936 of file Revision.php.

References getRecentChange().

◆ loadFromConds()

static Revision::loadFromConds (   $db,
  $conditions,
  $flags = 0 
)
staticprivate

Given a set of conditions, fetch a revision from the given database connection.

Parameters
IDatabase$db
array$conditions
int$flags(optional)
Returns
Revision|null

Definition at line 342 of file Revision.php.

References $flags, $res, $ret, and fetchFromConds().

Referenced by loadFromId(), loadFromPageId(), loadFromTimestamp(), loadFromTitle(), newFromConds(), newFromPageId(), and newFromTitle().

◆ loadFromId()

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.

Parameters
IDatabase$db
int$id
Returns
Revision|null

Definition at line 231 of file Revision.php.

References loadFromConds().

◆ loadFromPageId()

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.

Parameters
IDatabase$db
int$pageid
int$id
Returns
Revision|null

Definition at line 245 of file Revision.php.

References loadFromConds().

Referenced by Maintenance\updateSearchIndexForPage().

◆ loadFromTimestamp()

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.

Parameters
IDatabase$db
Title$title
string$timestamp
Returns
Revision|null

Definition at line 290 of file Revision.php.

References $timestamp, $title, and loadFromConds().

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

◆ loadFromTitle()

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.

Parameters
IDatabase$db
Title$title
int$id
Returns
Revision|null

Definition at line 265 of file Revision.php.

References $title, and loadFromConds().

Referenced by EditPage\mergeChangesIntoContent().

◆ loadText()

Revision::loadText ( )
protected

Lazy-load the revision's text.

Currently hardcoded to the 'text' table storage engine.

Returns
string|bool The revision's text, or false on failure

Definition at line 1539 of file Revision.php.

References $cache, $dbr, $mTextRow, $wgRevisionCacheExpiry, DB_MASTER, DB_SLAVE, ObjectCache\getMainWANInstance(), getRevisionText(), getTextId(), global, IDBAccessObject\READ_LOCKING, wfDebug(), wfDebugLog(), wfGetDB(), wfGetLB(), and wfMemcKey().

Referenced by getContentInternal(), and getSerializedData().

◆ newFromArchiveRow()

static Revision::newFromArchiveRow (   $row,
  $overrides = [] 
)
static

◆ newFromConds()

static Revision::newFromConds (   $conditions,
  $flags = 0 
)
staticprivate

Given a set of conditions, fetch a revision.

This method is used then a revision ID is qualified and will incorporate some basic slave/master fallback logic

Parameters
array$conditions
int$flags(optional)
Returns
Revision|null

Definition at line 310 of file Revision.php.

References $flags, $rev, DB_MASTER, DB_SLAVE, loadFromConds(), IDBAccessObject\READ_LATEST, wfGetDB(), and wfGetLB().

Referenced by newFromId(), newFromPageId(), and newFromTitle().

◆ newFromId()

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 99 of file Revision.php.

References $flags, and newFromConds().

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

◆ newFromPageId()

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 148 of file Revision.php.

References $flags, $revId, DB_MASTER, DB_SLAVE, loadFromConds(), newFromConds(), and wfGetDB().

Referenced by NamespaceConflictChecker\canMerge(), ApiStashEdit\execute(), and WikiPage\loadLastEdit().

◆ newFromRow()

static Revision::newFromRow (   $row)
static

◆ newFromTitle()

static Revision::newFromTitle ( LinkTarget  $linkTarget,
  $id = 0,
  $flags = 0 
)
static

◆ newNullRevision()

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 1626 of file Revision.php.

References $summary, $user, $wgContentHandlerUseDB, $wgContLang, $wgUser, global, and Title\makeTitle().

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

◆ pageJoinCond()

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
Returns
array

Definition at line 420 of file Revision.php.

Referenced by ChangeTagsRevisionList\doQuery(), RevDelRevisionList\doQuery(), RevisionList\doQuery(), ContribsPager\getQueryInfo(), and MergeHistoryPager\getQueryInfo().

◆ selectArchiveFields()

static Revision::selectArchiveFields ( )
static

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

Returns
array

Definition at line 460 of file Revision.php.

References $wgContentHandlerUseDB, and global.

Referenced by PopulateRevisionLength\doDBUpdates(), RevDelArchiveList\doQuery(), RevDelRevisionList\doQuery(), ApiQueryAllDeletedRevisions\run(), and ApiQueryDeletedRevisions\run().

◆ selectFields()

◆ selectPageFields()

static Revision::selectPageFields ( )
static

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

Returns
array

Definition at line 502 of file Revision.php.

Referenced by RebuildTextIndex\populateSearchIndex(), ApiQueryAllRevisions\run(), and ApiQueryRevisions\run().

◆ selectTextFields()

static Revision::selectTextFields ( )
static

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

Returns
array

Definition at line 491 of file Revision.php.

Referenced by RebuildTextIndex\populateSearchIndex(), ApiQueryAllRevisions\run(), and ApiQueryRevisions\run().

◆ selectUserFields()

static Revision::selectUserFields ( )
static

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

Returns
array

Definition at line 517 of file Revision.php.

Referenced by ChangeTagsRevisionList\doQuery(), RevDelRevisionList\doQuery(), RevisionList\doQuery(), HistoryPager\getQueryInfo(), ContribsPager\getQueryInfo(), MergeHistoryPager\getQueryInfo(), and ApiQueryRevisions\run().

◆ setId()

Revision::setId (   $id)

Set the revision ID.

Since
1.19
Parameters
int$id

Definition at line 726 of file Revision.php.

◆ setTitle()

Revision::setTitle (   $title)

Set the title of the revision.

Parameters
Title$title

Definition at line 803 of file Revision.php.

References $title.

◆ userCan()

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 1694 of file Revision.php.

References $user, and userCanBitfield().

Referenced by ApiQueryRevisionsBase\extractRevisionInfo(), getComment(), getContent(), getUser(), and getUserText().

◆ userCanBitfield()

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 1712 of file Revision.php.

References $title, $user, $wgUser, as, global, and wfDebug().

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

◆ userJoinCond()

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
Returns
array

Definition at line 410 of file Revision.php.

Referenced by ChangeTagsRevisionList\doQuery(), RevDelRevisionList\doQuery(), RevisionList\doQuery(), HistoryPager\getQueryInfo(), ContribsPager\getQueryInfo(), MergeHistoryPager\getQueryInfo(), and ApiQueryRevisions\run().

◆ userWasLastToEdit()

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 1815 of file Revision.php.

References $res, as, and wfGetDB().

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

Member Data Documentation

◆ $mComment

Revision::$mComment
protected

Definition at line 43 of file Revision.php.

Referenced by getComment(), and insertOn().

◆ $mContent

Content null bool Revision::$mContent
protected

Definition at line 63 of file Revision.php.

◆ $mContentFormat

Revision::$mContentFormat
protected

Definition at line 58 of file Revision.php.

Referenced by getContentFormat().

◆ $mContentHandler

null ContentHandler Revision::$mContentHandler
protected

Definition at line 68 of file Revision.php.

Referenced by getContentHandler().

◆ $mContentModel

Revision::$mContentModel
protected

Definition at line 57 of file Revision.php.

Referenced by getContentModel().

◆ $mCurrent

Revision::$mCurrent
protected

Definition at line 56 of file Revision.php.

Referenced by isCurrent().

◆ $mDeleted

Revision::$mDeleted
protected

Definition at line 39 of file Revision.php.

Referenced by getVisibility(), and insertOn().

◆ $mId

Revision::$mId
protected

Definition at line 28 of file Revision.php.

Referenced by checkContentModel(), getId(), and insertOn().

◆ $mMinorEdit

Revision::$mMinorEdit
protected

Definition at line 37 of file Revision.php.

Referenced by isMinor().

◆ $mOrigUserText

Revision::$mOrigUserText
protected

Definition at line 35 of file Revision.php.

Referenced by getUserText().

◆ $mPage

int null Revision::$mPage
protected

Definition at line 33 of file Revision.php.

Referenced by getPage(), and insertOn().

◆ $mParentId

Revision::$mParentId
protected

Definition at line 42 of file Revision.php.

Referenced by getParentId(), and insertOn().

◆ $mQueryFlags

int Revision::$mQueryFlags = 0
protected

Definition at line 73 of file Revision.php.

◆ $mSha1

Revision::$mSha1
protected

Definition at line 41 of file Revision.php.

Referenced by getSha1(), and insertOn().

◆ $mSize

Revision::$mSize
protected

Definition at line 40 of file Revision.php.

Referenced by getSize(), and insertOn().

◆ $mText

Revision::$mText
protected

Definition at line 44 of file Revision.php.

Referenced by getSerializedData(), and insertOn().

◆ $mTextId

Revision::$mTextId
protected

Definition at line 45 of file Revision.php.

Referenced by getTextId(), and insertOn().

◆ $mTextRow

stdClass null Revision::$mTextRow
protected

Definition at line 50 of file Revision.php.

Referenced by loadText().

◆ $mTimestamp

Revision::$mTimestamp
protected

Definition at line 38 of file Revision.php.

◆ $mTitle

null Title Revision::$mTitle
protected

Definition at line 55 of file Revision.php.

Referenced by getTitle().

◆ $mUser

Revision::$mUser
protected

Definition at line 36 of file Revision.php.

Referenced by getUser(), and insertOn().

◆ $mUserText

Revision::$mUserText
protected

Definition at line 34 of file Revision.php.

Referenced by getUserText(), and insertOn().

◆ DELETED_COMMENT

◆ DELETED_RESTRICTED

◆ DELETED_TEXT

const Revision::DELETED_TEXT = 1

Definition at line 76 of file Revision.php.

Referenced by RevDelRevisionItem\canViewContent(), RevisionItem\canViewContent(), CleanupSpam\cleanupArticle(), WikiPage\commitRollback(), HistoryPager\curLink(), HistoryPager\diffButtons(), LocalFileDeleteBatch\doDBInserts(), WikiPage\doDeleteArticleReal(), ApiEditPage\execute(), ApiParse\execute(), ApiQueryDeletedrevs\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(), RevDelRevisionList\getRevdelConstant(), DifferenceEngine\getRevisionHeader(), Linker\getRollbackEditCount(), HistoryPager\historyLine(), ChangesList\insertDiffHist(), RevDelRevisionItem\isDeleted(), RevisionItem\isDeleted(), RevDelRevisionItem\isHideCurrentOp(), HistoryPager\lastLink(), ApiQueryRevisionsBase\parseParameters(), HistoryPager\revLink(), Article\showDeletedRevisionHeader(), RCCacheEntryFactory\showDiffLinks(), DifferenceEngine\showDiffPage(), EditPage\showHeader(), SpecialUndelete\showRevision(), PageArchive\undeleteRevisions(), and XmlDumpWriter\writeRevision().

◆ DELETED_USER

◆ FOR_PUBLIC

◆ FOR_THIS_USER

◆ RAW

◆ SUPPRESSED_USER

const Revision::SUPPRESSED_USER = 12

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