BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
Revision Class Reference
Inheritance diagram for Revision:
Collaboration diagram for Revision:

Public Member Functions

 __construct ($row)
 
 getId ()
 
 setId ($id)
 
 getTextId ()
 
 getParentId ()
 
 getSize ()
 
 getSha1 ()
 
 getTitle ()
 
 setTitle ($title)
 
 getPage ()
 
 getUser ($audience=self::FOR_PUBLIC, User $user=null)
 
 getRawUser ()
 
 getUserText ($audience=self::FOR_PUBLIC, User $user=null)
 
 getRawUserText ()
 
 getComment ($audience=self::FOR_PUBLIC, User $user=null)
 
 getRawComment ()
 
 isMinor ()
 
 isUnpatrolled ()
 
 getRecentChange ($flags=0)
 
 isDeleted ($field)
 
 getVisibility ()
 
 getText ($audience=self::FOR_PUBLIC, User $user=null)
 
 getContent ($audience=self::FOR_PUBLIC, User $user=null)
 
 getSerializedData ()
 
 getContentModel ()
 
 getContentFormat ()
 
 getContentHandler ()
 
 getTimestamp ()
 
 isCurrent ()
 
 getPrevious ()
 
 getNext ()
 
 insertOn ($dbw)
 
 userCan ($field, User $user=null)
 

Static Public Member Functions

static newFromId ($id, $flags=0)
 
static newFromTitle (LinkTarget $linkTarget, $id=0, $flags=0)
 
static newFromPageId ($pageId, $revId=0, $flags=0)
 
static newFromArchiveRow ($row, $overrides=[])
 
static newFromRow ($row)
 
static loadFromId ($db, $id)
 
static loadFromPageId ($db, $pageid, $id=0)
 
static loadFromTitle ($db, $title, $id=0)
 
static loadFromTimestamp ($db, $title, $timestamp)
 
static fetchRevision ($title)
 
static userJoinCond ()
 
static pageJoinCond ()
 
static selectFields ()
 
static selectArchiveFields ()
 
static selectTextFields ()
 
static selectPageFields ()
 
static selectUserFields ()
 
static getParentLengths ($db, array $revIds)
 
static getRevisionText ($row, $prefix= 'old_', $wiki=false)
 
static compressRevisionText (&$text)
 
static decompressRevisionText ($text, $flags)
 
static base36Sha1 ($text)
 
static newNullRevision ($dbw, $pageId, $summary, $minor, $user=null)
 
static userCanBitfield ($bitfield, $field, User $user=null, Title $title=null)
 
static getTimestampFromId ($title, $id, $flags=0)
 
static countByPageId ($db, $id)
 
static countByTitle ($db, $title)
 
static userWasLastToEdit ($db, $pageId, $userId, $since)
 

Public Attributes

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

Protected Member Functions

 getContentInternal ()
 
 checkContentModel ()
 
 loadText ()
 

Protected Attributes

 $mId
 
 $mPage
 
 $mUserText
 
 $mOrigUserText
 
 $mUser
 
 $mMinorEdit
 
 $mTimestamp
 
 $mDeleted
 
 $mSize
 
 $mSha1
 
 $mParentId
 
 $mComment
 
 $mText
 
 $mTextId
 
 $mTextRow
 
 $mTitle
 
 $mCurrent
 
 $mContentModel
 
 $mContentFormat
 
 $mContent
 
 $mContentHandler
 
 $mQueryFlags = 0
 

Detailed Description

Todo:
document

Constructor & Destructor Documentation

Revision::__construct (   $row)

Constructor

Parameters
object | array$rowEither a database row or an array
Exceptions
MWExceptionprivate

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
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
static Revision::countByPageId (   $db,
  $id 
)
static

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

Parameters
IDatabase$db
int$idPage id
Returns
int
static Revision::countByTitle (   $db,
  $title 
)
static

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

Parameters
IDatabase$db
Title$title
Returns
int
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
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
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
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
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.
Revision::getContentHandler ( )

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

Exceptions
MWException
Returns
ContentHandler
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.
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.
Revision::getId ( )

Get revision ID

Returns
int|null
Revision::getNext ( )

Get next revision for this title

Returns
Revision|null
Revision::getPage ( )

Get the page ID

Returns
int|null
Revision::getParentId ( )

Get parent revision ID (the original previous page revision)

Returns
int|null
static Revision::getParentLengths (   $db,
array  $revIds 
)
static

Do a batched query to get the parent revision lengths

Parameters
IDatabase$db
array$revIds
Returns
array
Revision::getPrevious ( )

Get previous revision for this title

Returns
Revision|null
Revision::getRawComment ( )

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

Returns
string
Deprecated:
since 1.25, use getComment( Revision::RAW )
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 )
Revision::getRawUserText ( )

Fetch revision's username without regard for view restrictions

Returns
string
Deprecated:
since 1.25, use getUserText( Revision::RAW )
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
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
Revision::getSerializedData ( )

Fetch original serialized data without regard for view restrictions

Since
1.21
Returns
string
Revision::getSha1 ( )

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

Returns
string|null
Revision::getSize ( )

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

Returns
int|null
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
Revision::getTextId ( )

Get text row ID

Returns
int|null
Revision::getTimestamp ( )
Returns
string
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
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
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
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
Revision::getVisibility ( )

Get the deletion bitfield of the revision

Returns
int
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
Revision::isCurrent ( )
Returns
bool
Revision::isDeleted (   $field)
Parameters
int$fieldOne of DELETED_* bitfield constants
Returns
bool
Revision::isMinor ( )
Returns
bool
Revision::isUnpatrolled ( )
Returns
int Rcid of the unpatrolled row, zero if there isn't one
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
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
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
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
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
static Revision::newFromArchiveRow (   $row,
  $overrides = [] 
)
static

Make a fake revision object from an archive table row. This is queried for permissions or even inserted (as in Special:Undelete)

Todo:
FIXME: Should be a subclass for RevisionDelete. [TS]
Parameters
object$row
array$overrides
Exceptions
MWException
Returns
Revision
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
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
static Revision::newFromRow (   $row)
static
Since
1.19
Parameters
object$row
Returns
Revision
static Revision::newFromTitle ( LinkTarget  $linkTarget,
  $id = 0,
  $flags = 0 
)
static

Load either the current, or a specified, revision that's attached to a given link target. If not attached to that link target, will return null.

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

Parameters
LinkTarget$linkTarget
int$id(optional)
int$flagsBitfield (optional)
Returns
Revision|null
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
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
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
static Revision::selectFields ( )
static

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

Returns
array
static Revision::selectPageFields ( )
static

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

Returns
array
static Revision::selectTextFields ( )
static

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

Returns
array
static Revision::selectUserFields ( )
static

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

Returns
array
Revision::setId (   $id)

Set the revision ID

Since
1.19
Parameters
int$id
Revision::setTitle (   $title)

Set the title of the revision

Parameters
Title$title
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
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
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
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

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