Revision Class Reference

List of all members.

Public Member Functions

 Revision ($row)
 getId ()
 #@+
 getTextId ()
 Get text row ID.
 getParentId ()
 Get parent revision ID (the original previous page revision).
 getSize ()
 Returns the length of the text in this revision, or null if unknown.
 getTitle ()
 Returns the title of the page associated with this entry.
 setTitle ($title)
 Set the title of the revision.
 getPage ()
 Get the page ID.
 getUser ($audience=self::FOR_PUBLIC)
 Fetch revision's user id if it's available to the specified audience.
 getRawUser ()
 Fetch revision's user id without regard for the current user's permissions.
 getUserText ($audience=self::FOR_PUBLIC)
 Fetch revision's username if it's available to the specified audience.
 getRawUserText ()
 Fetch revision's username without regard for view restrictions.
 getComment ($audience=self::FOR_PUBLIC)
 Fetch revision comment if it's available to the specified audience.
 getRawComment ()
 Fetch revision comment without regard for the current user's permissions.
 isMinor ()
 isUnpatrolled ()
 isDeleted ($field)
 int $field one of DELETED_* bitfield constants
 getVisibility ()
 Get the deletion bitfield of the revision.
 getText ($audience=self::FOR_PUBLIC)
 Fetch revision text if it's available to the specified audience.
 revText ()
 Alias for getText(Revision::FOR_THIS_USER).
 getRawText ()
 Fetch revision text without regard for view restrictions.
 getTimestamp ()
 isCurrent ()
 getPrevious ()
 Get previous revision for this title.
 getNext ()
 insertOn ($dbw)
 Insert a new revision into the database, returning the new revision ID number on success and dies horribly on failure.
 userCan ($field)
 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 newFromId ($id)
 Load a page revision from a given revision ID number.
static newFromTitle ($title, $id=0)
 Load either the current, or a specified, revision that's attached to a given title.
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 loadFromTitle ($db, $title, $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 fetchAllRevisions ($title)
 Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn.
static fetchRevision ($title)
 Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn.
static selectFields ()
 Return the list of revision fields that should be selected to create a new revision.
static selectTextFields ()
 Return the list of text fields that should be selected to read the revision text.
static selectPageFields ()
 Return the list of page fields that should be selected from page table.
static getRevisionText ($row, $prefix= 'old_')
 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 compressRevisionText (&$text)
 If $wgCompressRevisions is enabled, we will compress data.
static newNullRevision ($dbw, $pageId, $summary, $minor)
 Create a new null-revision for insertion into a page's history.
static getTimestampFromId ($title, $id)
 Get rev_timestamp from rev_id, without loading the rest of the row.
static countByPageId ($db, $id)
 Get count of revisions per page.
static countByTitle ($db, $title)
 Get count of revisions per page.

Public Attributes

const DELETED_TEXT = 1
const DELETED_COMMENT = 2
const DELETED_USER = 4
const DELETED_RESTRICTED = 8
const FOR_PUBLIC = 1
const FOR_THIS_USER = 2
const RAW = 3

Private Member Functions

 getPreviousRevisionId ($db)
 Get previous revision Id for this page_id This is used to populate rev_parent_id on save.
 loadText ()
 Lazy-load the revision's text.

Static Private Member Functions

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


Detailed Description

Todo:
document

Definition at line 10 of file Revision.php.


Member Function Documentation

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 $text reference to a text
Returns:
string

Definition at line 772 of file Revision.php.

References $flags, $text, $wgCompressRevisions, and wfDebug().

Referenced by CheckStorage::importRevision(), insertOn(), ArticleTest::testCompressRevisionTextUtf8(), and ArticleTest::testCompressRevisionTextUtf8Gzip().

static Revision::countByPageId ( db,
id 
) [static]

Get count of revisions per page.

..not very efficient

Parameters:
Database $db
int $id, page id

Definition at line 1011 of file Revision.php.

References $db, and $row.

Referenced by countByTitle().

static Revision::countByTitle ( db,
title 
) [static]

Get count of revisions per page.

..not very efficient

Parameters:
Database $db
Title $title

Definition at line 1025 of file Revision.php.

References $db, $title, and countByPageId().

static Revision::fetchAllRevisions ( 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
Access:
public

Definition at line 205 of file Revision.php.

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

static Revision::fetchFromConds ( db,
conditions 
) [static, private]

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

Parameters:
Database $db
array $conditions
Returns:
ResultWrapper
Access:
private

Definition at line 243 of file Revision.php.

References $db, $fields, $res, and selectFields().

Referenced by fetchAllRevisions(), fetchRevision(), and loadFromConds().

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
Access:
public

Definition at line 223 of file Revision.php.

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

Revision::getComment ( audience = self::FOR_PUBLIC  ) 

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:
integer $audience One 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
Returns:
string

Definition at line 520 of file Revision.php.

References isDeleted(), and userCan().

Referenced by Linker::revComment().

Revision::getId (  ) 

#@+

Access:
public Get revision ID
Returns:
int

Definition at line 381 of file Revision.php.

Referenced by getNext(), getPrevious(), and isUnpatrolled().

Revision::getNext (  ) 

Returns:
Revision

Definition at line 654 of file Revision.php.

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

Revision::getPage (  ) 

Get the page ID.

Returns:
int

Definition at line 443 of file Revision.php.

Revision::getParentId (  ) 

Get parent revision ID (the original previous page revision).

Returns:
int

Definition at line 397 of file Revision.php.

Revision::getPrevious (  ) 

Get previous revision for this title.

Returns:
Revision

Definition at line 641 of file Revision.php.

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

Revision::getPreviousRevisionId ( db  )  [private]

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

Parameters:
Database $db
Returns:
int

Definition at line 670 of file Revision.php.

References $db.

Referenced by insertOn().

Revision::getRawComment (  ) 

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

Returns:
string

Definition at line 534 of file Revision.php.

Revision::getRawText (  ) 

Fetch revision text without regard for view restrictions.

Returns:
string

Definition at line 615 of file Revision.php.

References loadText().

Referenced by getText().

Revision::getRawUser (  ) 

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

Returns:
string

Definition at line 474 of file Revision.php.

Revision::getRawUserText (  ) 

Fetch revision's username without regard for view restrictions.

Returns:
string

Definition at line 504 of file Revision.php.

Referenced by isUnpatrolled().

static Revision::getRevisionText ( row,
prefix = 'old_' 
) [static]

Revision::getSize (  ) 

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

Returns:
int

Definition at line 405 of file Revision.php.

Revision::getText ( audience = self::FOR_PUBLIC  ) 

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:
integer $audience One 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
Returns:
string

Definition at line 594 of file Revision.php.

References getRawText(), isDeleted(), and userCan().

Referenced by Article::getUndoText(), and revText().

Revision::getTextId (  ) 

Get text row ID.

Returns:
int

Definition at line 389 of file Revision.php.

Referenced by loadText().

Revision::getTimestamp (  ) 

Returns:
string

Definition at line 626 of file Revision.php.

References wfTimestamp().

static Revision::getTimestampFromId ( title,
id 
) [static]

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

Parameters:
Title $title
integer $id

Definition at line 989 of file Revision.php.

References $conds, $dbr, $dbw, $title, wfGetDB(), wfGetLB(), and wfTimestamp().

Referenced by lastModified().

Revision::getTitle (  ) 

Returns the title of the page associated with this entry.

Returns:
Title

Definition at line 413 of file Revision.php.

References $dbr, $row, Title::makeTitle(), and wfGetDB().

Referenced by getNext(), getPrevious(), and Linker::revComment().

Revision::getUser ( audience = self::FOR_PUBLIC  ) 

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:
integer $audience One of: Revision::FOR_PUBLIC to be displayed to all users Revision::FOR_THIS_USER to be displayed to $wgUser Revision::RAW get the ID regardless of permissions
Returns:
int

Definition at line 460 of file Revision.php.

References isDeleted(), and userCan().

Revision::getUserText ( audience = self::FOR_PUBLIC  ) 

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:
integer $audience One 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
Returns:
string

Definition at line 490 of file Revision.php.

References isDeleted(), and userCan().

Revision::getVisibility (  ) 

Get the deletion bitfield of the revision.

Definition at line 577 of file Revision.php.

Revision::insertOn ( dbw  ) 

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

Parameters:
Database $dbw
Returns:
int

Definition at line 798 of file Revision.php.

References $dbw, $flags, $wgDefaultExternalStore, compressRevisionText(), getPreviousRevisionId(), ExternalStore::insertToDefault(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Revision::isCurrent (  ) 

Returns:
bool

Definition at line 633 of file Revision.php.

Revision::isDeleted ( field  ) 

int $field one of DELETED_* bitfield constants

Returns:
bool

Definition at line 570 of file Revision.php.

Referenced by getComment(), getText(), getUser(), getUserText(), and Linker::revComment().

Revision::isMinor (  ) 

Returns:
bool

Definition at line 541 of file Revision.php.

Revision::isUnpatrolled (  ) 

Returns:
int rcid of the unpatrolled row, zero if there isn't one

Definition at line 548 of file Revision.php.

References $dbr, getId(), getRawUserText(), and wfGetDB().

static Revision::loadFromConds ( db,
conditions 
) [static, private]

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

Parameters:
Database $db
array $conditions
Returns:
Revision
Access:
private

Definition at line 181 of file Revision.php.

References $db, $res, $row, fetchFromConds(), and Revision().

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

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:
Database $db
int $id
Access:
public

Definition at line 78 of file Revision.php.

References $db, and loadFromConds().

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:
Database $db
int $pageid
int $id
Returns:
Revision
Access:
public

Definition at line 96 of file Revision.php.

References $conds, $db, and loadFromConds().

Referenced by Article::loadLastEdit(), and updateSearchIndex().

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:
Database $db
Title $title
string $timestamp
Returns:
Revision
Access:
public

Definition at line 144 of file Revision.php.

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

Referenced by EditPage::getBaseRevision(), and Article::replaceSection().

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:
Database $db
Title $title
int $id
Returns:
Revision
Access:
public

Definition at line 118 of file Revision.php.

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

Referenced by EditPage::mergeChangesInto().

Revision::loadText (  )  [private]

Lazy-load the revision's text.

Currently hardcoded to the 'text' table storage engine.

Returns:
string

Definition at line 867 of file Revision.php.

References $dbr, $dbw, $key, $row, $text, $wgMemc, $wgRevisionCacheExpiry, getRevisionText(), getTextId(), wfGetDB(), wfGetLB(), wfMemcKey(), wfProfileIn(), and wfProfileOut().

Referenced by getRawText().

static Revision::newFromConds ( conditions  )  [static, private]

Given a set of conditions, fetch a revision.

Parameters:
array $conditions
Returns:
Revision
Access:
private

Definition at line 161 of file Revision.php.

References $db, $dbw, $row, loadFromConds(), wfGetDB(), and wfGetLB().

Referenced by newFromId(), and newFromTitle().

static Revision::newFromId ( id  )  [static]

static Revision::newFromTitle ( title,
id = 0 
) [static]

static Revision::newNullRevision ( dbw,
pageId,
summary,
minor 
) [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:
Database $dbw
int $pageId ID number of the page to read from
string $summary
bool $minor
Returns:
Revision

Definition at line 933 of file Revision.php.

References $dbw, $minor, $revision, $summary, Revision(), wfProfileIn(), and wfProfileOut().

Referenced by Title::moveOverExistingRedirect(), Title::moveToNewTitle(), LocalFile::recordUpload2(), ImportReporter::reportPage(), and Article::updateRestrictions().

Revision::Revision ( row  ) 

Parameters:
object $row
Access:
private

Definition at line 303 of file Revision.php.

References $row, $wgUser, Title::makeTitle(), and wfTimestamp().

Referenced by loadFromConds(), and newNullRevision().

Revision::revText (  ) 

Alias for getText(Revision::FOR_THIS_USER).

Definition at line 607 of file Revision.php.

References getText().

static Revision::selectFields (  )  [static]

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

Definition at line 262 of file Revision.php.

Referenced by ApiQueryRevisions::execute(), fetchFromConds(), PageHistory::fetchRevisions(), and PageHistoryPager::getQueryInfo().

static Revision::selectPageFields (  )  [static]

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

Definition at line 291 of file Revision.php.

Referenced by ApiQueryRevisions::execute().

static Revision::selectTextFields (  )  [static]

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

Definition at line 282 of file Revision.php.

Referenced by ApiQueryRevisions::execute().

Revision::setTitle ( title  ) 

Set the title of the revision.

Parameters:
Title $title

Definition at line 435 of file Revision.php.

References $title.

Revision::userCan ( field  ) 

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

Parameters:
int $field one of self::DELETED_TEXT, self::DELETED_COMMENT, self::DELETED_USER
Returns:
bool

Definition at line 970 of file Revision.php.

References $wgUser, and wfDebug().

Referenced by getComment(), getText(), getUser(), getUserText(), and Linker::revComment().


Member Data Documentation

Definition at line 17 of file Revision.php.

const Revision::RAW = 3

Definition at line 19 of file Revision.php.


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

Generated on Sat Sep 5 02:08:45 2009 for MediaWiki by  doxygen 1.5.9