MediaWiki  REL1_31
MediaWiki\Storage\RevisionStore Class Reference

Service for looking up page revisions. More...

Inheritance diagram for MediaWiki\Storage\RevisionStore:
Collaboration diagram for MediaWiki\Storage\RevisionStore:

Public Member Functions

 __construct (LoadBalancer $loadBalancer, SqlBlobStore $blobStore, WANObjectCache $cache, CommentStore $commentStore, ActorMigration $actorMigration, $wikiId=false)
 
 countRevisionsByPageId (IDatabase $db, $id)
 Get count of revisions per page...not very efficient. More...
 
 countRevisionsByTitle (IDatabase $db, $title)
 Get count of revisions per page...not very efficient. More...
 
 getArchiveQueryInfo ()
 Return the tables, fields, and join conditions to be selected to create a new archived revision object. More...
 
 getContentHandlerUseDB ()
 
 getKnownCurrentRevision (Title $title, $revId)
 Load a revision based on a known page ID and current revision ID from the DB. More...
 
 getNextRevision (RevisionRecord $rev, Title $title=null)
 Get next revision for this title. More...
 
 getPreviousRevision (RevisionRecord $rev, Title $title=null)
 Get previous revision for this title. More...
 
 getQueryInfo ( $options=[])
 Return the tables, fields, and join conditions to be selected to create a new revision object. More...
 
 getRcIdIfUnpatrolled (RevisionRecord $rev)
 MCR migration note: this replaces Revision::isUnpatrolled. More...
 
 getRecentChange (RevisionRecord $rev, $flags=0)
 Get the RC object belonging to the current revision, if there's one. More...
 
 getRevisionById ( $id, $flags=0)
 Load a page revision from a given revision ID number. More...
 
 getRevisionByPageId ( $pageId, $revId=0, $flags=0)
 Load either the current, or a specified, revision that's attached to a given page ID. More...
 
 getRevisionByTimestamp ( $title, $timestamp)
 Load the revision for the given title with the given timestamp. More...
 
 getRevisionByTitle (LinkTarget $linkTarget, $revId=0, $flags=0)
 Load either the current, or a specified, revision that's attached to a given link target. More...
 
 getRevisionSizes (array $revIds)
 Do a batched query for the sizes of a set of revisions. More...
 
 getTimestampFromId ( $title, $id, $flags=0)
 Get rev_timestamp from rev_id, without loading the rest of the row. More...
 
 getTitle ( $pageId, $revId, $queryFlags=self::READ_NORMAL)
 Determines the page Title based on the available information. More...
 
 insertRevisionOn (RevisionRecord $rev, IDatabase $dbw)
 Insert a new revision into the database, returning the new revision record on success and dies horribly on failure. More...
 
 isReadOnly ()
 
 listRevisionSizes (IDatabase $db, array $revIds)
 Do a batched query for the sizes of a set of revisions. More...
 
 loadRevisionFromId (IDatabase $db, $id)
 Load a page revision from a given revision ID number. More...
 
 loadRevisionFromPageId (IDatabase $db, $pageid, $id=0)
 Load either the current, or a specified, revision that's attached to a given page. More...
 
 loadRevisionFromTimestamp (IDatabase $db, $title, $timestamp)
 Load the revision for the given title with the given timestamp. More...
 
 loadRevisionFromTitle (IDatabase $db, $title, $id=0)
 Load either the current, or a specified, revision that's attached to a given page. More...
 
 newMutableRevisionFromArray (array $fields, $queryFlags=0, Title $title=null)
 Constructs a new MutableRevisionRecord based on the given associative array following the MW1.29 convention for the Revision constructor. More...
 
 newNullRevision (IDatabase $dbw, Title $title, CommentStoreComment $comment, $minor, User $user)
 Create a new null-revision for insertion into a page's history. More...
 
 newRevisionFromArchiveRow ( $row, $queryFlags=0, Title $title=null, array $overrides=[])
 Make a fake revision object from an archive table row. More...
 
 newRevisionFromRow ( $row, $queryFlags=0, Title $title=null)
 
 setContentHandlerUseDB ( $contentHandlerUseDB)
 
 setLogger (LoggerInterface $logger)
 
 userWasLastToEdit (IDatabase $db, $pageId, $userId, $since)
 Check if no edits were made by other users since the time a user started editing the page. More...
 

Private Member Functions

 checkContentModel (Content $content, Title $title)
 MCR migration note: this corresponds to Revision::checkContentModel. More...
 
 checkDatabaseWikiId (IDatabase $db)
 Throws an exception if the given database connection does not belong to the wiki this RevisionStore is bound to. More...
 
 emulateMainSlot_1_29 ( $row, $queryFlags, Title $title)
 Constructs a RevisionRecord for the revisions main slot, based on the MW1.29 schema. More...
 
 failOnEmpty ( $value, $name)
 
 failOnNull ( $value, $name)
 
 fetchRevisionRowFromConds (IDatabase $db, $conditions, $flags=0)
 Given a set of conditions, return a row with the fields necessary to build RevisionRecord objects. More...
 
 getDBConnection ( $mode)
 
 getDBConnectionRef ( $mode)
 
 getDBLoadBalancer ()
 
 getPreviousRevisionId (IDatabase $db, RevisionRecord $rev)
 Get previous revision Id for this page_id This is used to populate rev_parent_id on save. More...
 
 initializeMutableRevisionFromArray (MutableRevisionRecord $record, array $fields)
 
 loadRevisionFromConds (IDatabase $db, $conditions, $flags=0, Title $title=null)
 Given a set of conditions, fetch a revision from the given database connection. More...
 
 loadSlotContent (SlotRecord $slot, $blobData=null, $blobFlags=null, $blobFormat=null, $queryFlags=0)
 Loads a Content object based on a slot row. More...
 
 newRevisionFromConds ( $conditions, $flags=0, Title $title=null)
 Given a set of conditions, fetch a revision. More...
 
 newRevisionFromRow_1_29 ( $row, $queryFlags=0, Title $title=null)
 
 releaseDBConnection (IDatabase $connection)
 

Static Private Member Functions

static mapArchiveFields ( $archiveRow)
 Maps fields of the archive row to corresponding revision rows. More...
 

Private Attributes

ActorMigration $actorMigration
 
SqlBlobStore $blobStore
 
WANObjectCache $cache
 
CommentStore $commentStore
 
boolean $contentHandlerUseDB = true
 
LoadBalancer $loadBalancer
 
LoggerInterface $logger
 
bool string $wikiId
 

Additional Inherited Members

- Public Attributes inherited from IDBAccessObject
const READ_LOCKING = 3
 Constants for object loading bitfield flags (higher => higher QoS) More...
 
const READ_NONE = -1
 

Detailed Description

Service for looking up page revisions.

Since
1.31
Note
This was written to act as a drop-in replacement for the corresponding static methods in Revision.

Definition at line 68 of file RevisionStore.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\RevisionStore::__construct ( LoadBalancer  $loadBalancer,
SqlBlobStore  $blobStore,
WANObjectCache  $cache,
CommentStore  $commentStore,
ActorMigration  $actorMigration,
  $wikiId = false 
)

Member Function Documentation

◆ checkContentModel()

MediaWiki\Storage\RevisionStore::checkContentModel ( Content  $content,
Title  $title 
)
private

◆ checkDatabaseWikiId()

◆ countRevisionsByPageId()

MediaWiki\Storage\RevisionStore::countRevisionsByPageId ( IDatabase  $db,
  $id 
)

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

MCR migration note: this replaces Revision::countByPageId

Parameters
IDatabase$db
int$idPage id
Returns
int

Definition at line 1877 of file RevisionStore.php.

References MediaWiki\Storage\RevisionStore\checkDatabaseWikiId(), and Wikimedia\Rdbms\IDatabase\selectRow().

Referenced by MediaWiki\Storage\RevisionStore\countRevisionsByTitle().

◆ countRevisionsByTitle()

MediaWiki\Storage\RevisionStore::countRevisionsByTitle ( IDatabase  $db,
  $title 
)

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

MCR migration note: this replaces Revision::countByTitle

Parameters
IDatabase$db
Title$title
Returns
int

Definition at line 1900 of file RevisionStore.php.

References $title, and MediaWiki\Storage\RevisionStore\countRevisionsByPageId().

◆ emulateMainSlot_1_29()

MediaWiki\Storage\RevisionStore::emulateMainSlot_1_29 (   $row,
  $queryFlags,
Title  $title 
)
private

Constructs a RevisionRecord for the revisions main slot, based on the MW1.29 schema.

Parameters
object | array$rowEither a database row or an array
int$queryFlagsfor callbacks
Title$title
Returns
SlotRecord The main slot, extracted from the MW 1.29 style row.
Exceptions
MWException

Definition at line 747 of file RevisionStore.php.

References $handler, $title, ContentHandler\getDefaultModelFor(), MediaWiki\Storage\RevisionStore\loadSlotContent(), MediaWiki\Storage\RevisionStore\mapArchiveFields(), and use.

Referenced by MediaWiki\Storage\RevisionStore\newMutableRevisionFromArray(), MediaWiki\Storage\RevisionStore\newNullRevision(), MediaWiki\Storage\RevisionStore\newRevisionFromArchiveRow(), and MediaWiki\Storage\RevisionStore\newRevisionFromRow_1_29().

◆ failOnEmpty()

MediaWiki\Storage\RevisionStore::failOnEmpty (   $value,
  $name 
)
private
Parameters
mixed$value
string$name
Exceptions
IncompleteRevisionExceptionif $value is empty
Returns
mixed $value, if $value is not null

Definition at line 306 of file RevisionStore.php.

References $value.

Referenced by MediaWiki\Storage\RevisionStore\insertRevisionOn().

◆ failOnNull()

MediaWiki\Storage\RevisionStore::failOnNull (   $value,
  $name 
)
private
Parameters
mixed$value
string$name
Exceptions
IncompleteRevisionExceptionif $value is null
Returns
mixed $value, if $value is not null

Definition at line 289 of file RevisionStore.php.

References $value.

Referenced by MediaWiki\Storage\RevisionStore\insertRevisionOn().

◆ fetchRevisionRowFromConds()

MediaWiki\Storage\RevisionStore::fetchRevisionRowFromConds ( IDatabase  $db,
  $conditions,
  $flags = 0 
)
private

Given a set of conditions, return a row with the fields necessary to build RevisionRecord objects.

MCR migration note: this corresponds to Revision::fetchFromConds

Parameters
IDatabase$db
array$conditions
int$flags(optional)
Returns
object|false data row as a raw object

Definition at line 1573 of file RevisionStore.php.

References $options, $revQuery, MediaWiki\Storage\RevisionStore\checkDatabaseWikiId(), MediaWiki\Storage\RevisionStore\getQueryInfo(), and Wikimedia\Rdbms\IDatabase\selectRow().

Referenced by MediaWiki\Storage\RevisionStore\getKnownCurrentRevision(), and MediaWiki\Storage\RevisionStore\loadRevisionFromConds().

◆ getArchiveQueryInfo()

MediaWiki\Storage\RevisionStore::getArchiveQueryInfo ( )

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

MCR migration note: this replaces Revision::getArchiveQueryInfo

Since
1.31
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 1691 of file RevisionStore.php.

References $ret.

◆ getContentHandlerUseDB()

MediaWiki\Storage\RevisionStore::getContentHandlerUseDB ( )
Returns
bool

Definition at line 154 of file RevisionStore.php.

References MediaWiki\Storage\RevisionStore\$contentHandlerUseDB.

◆ getDBConnection()

◆ getDBConnectionRef()

MediaWiki\Storage\RevisionStore::getDBConnectionRef (   $mode)
private
Parameters
int$modeDB_MASTER or DB_REPLICA
Returns
DBConnRef

Definition at line 195 of file RevisionStore.php.

References MediaWiki\Storage\RevisionStore\getDBLoadBalancer().

Referenced by MediaWiki\Storage\RevisionStore\getKnownCurrentRevision(), and MediaWiki\Storage\RevisionStore\getTitle().

◆ getDBLoadBalancer()

◆ getKnownCurrentRevision()

MediaWiki\Storage\RevisionStore::getKnownCurrentRevision ( Title  $title,
  $revId 
)

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.

MCR migration note: this replaces Revision::newKnownCurrent

Parameters
Title$titlethe associated page title
int$revIdcurrent revision of this page. Defaults to $title->getLatestRevID().
Returns
RevisionRecord|bool Returns false if missing

Implements MediaWiki\Storage\RevisionLookup.

Definition at line 1968 of file RevisionStore.php.

References $title, array(), cache, DB_REPLICA, MediaWiki\Storage\RevisionStore\fetchRevisionRowFromConds(), function, Wikimedia\Rdbms\Database\getCacheSetOptions(), MediaWiki\Storage\RevisionStore\getDBConnectionRef(), MediaWiki\Storage\RevisionStore\newRevisionFromRow(), IExpiringStore\TTL_WEEK, use, and wfWarn().

◆ getNextRevision()

MediaWiki\Storage\RevisionStore::getNextRevision ( RevisionRecord  $rev,
Title  $title = null 
)

Get next revision for this title.

MCR migration note: this replaces Revision::getNext

Parameters
RevisionRecord$rev
Title$titleif known (optional)
Returns
RevisionRecord|null

Implements MediaWiki\Storage\RevisionLookup.

Definition at line 1799 of file RevisionStore.php.

References $rev, $title, MediaWiki\Storage\RevisionRecord\getPageId(), MediaWiki\Storage\RevisionStore\getRevisionByTitle(), and MediaWiki\Storage\RevisionStore\getTitle().

◆ getPreviousRevision()

MediaWiki\Storage\RevisionStore::getPreviousRevision ( RevisionRecord  $rev,
Title  $title = null 
)

Get previous revision for this title.

MCR migration note: this replaces Revision::getPrevious

Parameters
RevisionRecord$rev
Title$titleif known (optional)
Returns
RevisionRecord|null

Implements MediaWiki\Storage\RevisionLookup.

Definition at line 1778 of file RevisionStore.php.

References $rev, $title, MediaWiki\Storage\RevisionRecord\getPageId(), MediaWiki\Storage\RevisionStore\getRevisionByTitle(), and MediaWiki\Storage\RevisionStore\getTitle().

◆ getPreviousRevisionId()

MediaWiki\Storage\RevisionStore::getPreviousRevisionId ( IDatabase  $db,
RevisionRecord  $rev 
)
private

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

MCR migration note: this corresponds to Revision::getPreviousRevisionId

Parameters
IDatabase$db
RevisionRecord$rev
Returns
int

Definition at line 1821 of file RevisionStore.php.

References $rev, MediaWiki\Storage\RevisionStore\checkDatabaseWikiId(), and Wikimedia\Rdbms\IDatabase\selectField().

Referenced by MediaWiki\Storage\RevisionStore\insertRevisionOn().

◆ getQueryInfo()

MediaWiki\Storage\RevisionStore::getQueryInfo (   $options = [])

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

MCR migration note: this replaces Revision::getQueryInfo

Since
1.31
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 1609 of file RevisionStore.php.

References $options, and $ret.

Referenced by MediaWiki\Storage\RevisionStore\fetchRevisionRowFromConds(), and MediaWiki\Storage\RevisionStore\userWasLastToEdit().

◆ getRcIdIfUnpatrolled()

MediaWiki\Storage\RevisionStore::getRcIdIfUnpatrolled ( RevisionRecord  $rev)

MCR migration note: this replaces Revision::isUnpatrolled.

Todo:
This is overly specific, so move or kill this method.
Parameters
RevisionRecord$rev
Returns
int Rcid of the unpatrolled row, zero if there isn't one

Definition at line 637 of file RevisionStore.php.

References MediaWiki\Storage\RevisionStore\getRecentChange(), and RecentChange\PRC_UNPATROLLED.

◆ getRecentChange()

MediaWiki\Storage\RevisionStore::getRecentChange ( RevisionRecord  $rev,
  $flags = 0 
)

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

MCR migration note: this replaces Revision::getRecentChange

Todo:
move this somewhere else?
Parameters
RevisionRecord$rev
int$flags(optional) $flags include: IDBAccessObject::READ_LATEST: Select the data from the master
Returns
null|RecentChange

Definition at line 659 of file RevisionStore.php.

References $dbr, $rev, DB_REPLICA, MediaWiki\Storage\RevisionStore\getDBConnection(), DBAccessObjectUtils\getDBOptions(), list, RecentChange\newFromConds(), MediaWiki\Storage\RevisionRecord\RAW, and MediaWiki\Storage\RevisionStore\releaseDBConnection().

Referenced by MediaWiki\Storage\RevisionStore\getRcIdIfUnpatrolled().

◆ getRevisionById()

MediaWiki\Storage\RevisionStore::getRevisionById (   $id,
  $flags = 0 
)

Load a page revision from a given revision ID number.

Returns null if no such revision can be found.

MCR migration note: this replaces Revision::newFromId

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

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

Implements MediaWiki\Storage\RevisionLookup.

Definition at line 950 of file RevisionStore.php.

References MediaWiki\Storage\RevisionStore\newRevisionFromConds().

◆ getRevisionByPageId()

MediaWiki\Storage\RevisionStore::getRevisionByPageId (   $pageId,
  $revId = 0,
  $flags = 0 
)

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.

MCR migration note: this replaces Revision::newFromPageId

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

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

Implements MediaWiki\Storage\RevisionLookup.

Definition at line 1015 of file RevisionStore.php.

References $rev, DB_MASTER, DB_REPLICA, MediaWiki\Storage\RevisionStore\getDBConnection(), MediaWiki\Storage\RevisionStore\loadRevisionFromConds(), MediaWiki\Storage\RevisionStore\newRevisionFromConds(), and MediaWiki\Storage\RevisionStore\releaseDBConnection().

◆ getRevisionByTimestamp()

MediaWiki\Storage\RevisionStore::getRevisionByTimestamp (   $title,
  $timestamp 
)

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.

MCR migration note: this replaces Revision::loadFromTimestamp

Parameters
Title$title
string$timestamp
Returns
RevisionRecord|null

Definition at line 1052 of file RevisionStore.php.

References $title, DB_REPLICA, MediaWiki\Storage\RevisionStore\getDBConnection(), and MediaWiki\Storage\RevisionStore\newRevisionFromConds().

◆ getRevisionByTitle()

MediaWiki\Storage\RevisionStore::getRevisionByTitle ( LinkTarget  $linkTarget,
  $revId = 0,
  $flags = 0 
)

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.

MCR migration note: this replaces Revision::newFromTitle

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

Parameters
LinkTarget$linkTarget
int$revId(optional)
int$flagsBitfield (optional)
Returns
RevisionRecord|null

Implements MediaWiki\Storage\RevisionLookup.

Definition at line 970 of file RevisionStore.php.

References $rev, DB_MASTER, DB_REPLICA, MediaWiki\Storage\RevisionStore\getDBConnection(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), MediaWiki\Storage\RevisionStore\loadRevisionFromConds(), MediaWiki\Storage\RevisionStore\newRevisionFromConds(), and MediaWiki\Storage\RevisionStore\releaseDBConnection().

Referenced by MediaWiki\Storage\RevisionStore\getNextRevision(), and MediaWiki\Storage\RevisionStore\getPreviousRevision().

◆ getRevisionSizes()

MediaWiki\Storage\RevisionStore::getRevisionSizes ( array  $revIds)

Do a batched query for the sizes of a set of revisions.

MCR migration note: this replaces Revision::getParentLengths

Parameters
int[]$revIds
Returns
int[] associative array mapping revision IDs from $revIds to the nominal size of the corresponding revision.

Definition at line 1730 of file RevisionStore.php.

References DB_REPLICA, MediaWiki\Storage\RevisionStore\getDBConnection(), and MediaWiki\Storage\RevisionStore\listRevisionSizes().

◆ getTimestampFromId()

MediaWiki\Storage\RevisionStore::getTimestampFromId (   $title,
  $id,
  $flags = 0 
)

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

MCR migration note: this replaces Revision::getTimestampFromId

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

Definition at line 1855 of file RevisionStore.php.

References $title, DB_MASTER, DB_REPLICA, MediaWiki\Storage\RevisionStore\getDBConnection(), MediaWiki\Storage\RevisionStore\releaseDBConnection(), and wfTimestamp().

◆ getTitle()

MediaWiki\Storage\RevisionStore::getTitle (   $pageId,
  $revId,
  $queryFlags = self::READ_NORMAL 
)

Determines the page Title based on the available information.

MCR migration note: this corresponds to Revision::getTitle

Note
this method should be private, external use should be avoided!
Parameters
int | null$pageId
int | null$revId
int$queryFlags
Returns
Title
Exceptions
RevisionAccessException

Definition at line 214 of file RevisionStore.php.

References $dbr, $title, DB_MASTER, false, Title\GAID_FOR_UPDATE, MediaWiki\Storage\RevisionStore\getDBConnectionRef(), DBAccessObjectUtils\getDBOptions(), DBAccessObjectUtils\hasFlags(), list, Title\newFromID(), Title\newFromRow(), and wfBacktrace().

Referenced by MediaWiki\Storage\RevisionStore\getNextRevision(), MediaWiki\Storage\RevisionStore\getPreviousRevision(), MediaWiki\Storage\RevisionStore\newMutableRevisionFromArray(), and MediaWiki\Storage\RevisionStore\newRevisionFromRow_1_29().

◆ initializeMutableRevisionFromArray()

◆ insertRevisionOn()

MediaWiki\Storage\RevisionStore::insertRevisionOn ( RevisionRecord  $rev,
IDatabase  $dbw 
)

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

MCR migration note: this replaces Revision::insertOn

Parameters
RevisionRecord$rev
IDatabase$dbw(master connection)
Exceptions
InvalidArgumentException
Returns
RevisionRecord the new revision record.

Definition at line 328 of file RevisionStore.php.

References $rev, $title, $user, MediaWiki\Storage\RevisionStore\checkContentModel(), MediaWiki\Storage\RevisionStore\checkDatabaseWikiId(), MediaWiki\Storage\BlobStore\DESIGNATION_HINT, MediaWiki\Storage\RevisionStore\failOnEmpty(), MediaWiki\Storage\RevisionStore\failOnNull(), MediaWiki\Storage\BlobStore\FORMAT_HINT, MediaWiki\Storage\RevisionRecord\getComment(), ContentHandler\getDefaultModelFor(), ContentHandler\getForModelID(), MediaWiki\Storage\RevisionRecord\getPageId(), MediaWiki\Storage\RevisionStore\getPreviousRevisionId(), MediaWiki\Storage\RevisionRecord\getSha1(), MediaWiki\Storage\RevisionRecord\getSize(), MediaWiki\Storage\RevisionRecord\getTimestamp(), MediaWiki\Storage\RevisionRecord\getUser(), Wikimedia\Rdbms\IDatabase\insert(), Wikimedia\Rdbms\IDatabase\insertId(), IP\isValid(), list, MediaWiki\Storage\BlobStore\MODEL_HINT, Title\newFromLinkTarget(), MediaWiki\Storage\SlotRecord\newSaved(), MediaWiki\Storage\BlobStore\PAGE_HINT, MediaWiki\Storage\BlobStore\PARENT_HINT, MediaWiki\Storage\RevisionRecord\RAW, MediaWiki\Storage\BlobStore\ROLE_HINT, Hooks\run(), MediaWiki\Storage\BlobStore\SHA1_HINT, Wikimedia\Rdbms\IDatabase\timestamp(), and IP\toHex().

◆ isReadOnly()

MediaWiki\Storage\RevisionStore::isReadOnly ( )
Returns
bool Whether the store is read-only

Definition at line 147 of file RevisionStore.php.

◆ listRevisionSizes()

MediaWiki\Storage\RevisionStore::listRevisionSizes ( IDatabase  $db,
array  $revIds 
)

Do a batched query for the sizes of a set of revisions.

MCR migration note: this replaces Revision::getParentLengths

Deprecated:
use RevisionStore::getRevisionSizes instead.
Parameters
IDatabase$db
int[]$revIds
Returns
int[] associative array mapping revision IDs from $revIds to the nominal size of the corresponding revision.

Definition at line 1746 of file RevisionStore.php.

References $res, as, MediaWiki\Storage\RevisionStore\checkDatabaseWikiId(), and Wikimedia\Rdbms\IDatabase\select().

Referenced by MediaWiki\Storage\RevisionStore\getRevisionSizes().

◆ loadRevisionFromConds()

MediaWiki\Storage\RevisionStore::loadRevisionFromConds ( IDatabase  $db,
  $conditions,
  $flags = 0,
Title  $title = null 
)
private

◆ loadRevisionFromId()

MediaWiki\Storage\RevisionStore::loadRevisionFromId ( IDatabase  $db,
  $id 
)

Load a page revision from a given revision ID number.

Returns null if no such revision can be found.

MCR migration note: this corresponds to Revision::loadFromId

Note
direct use is deprecated!
Todo:
remove when unused! there seem to be no callers of Revision::loadFromId
Parameters
IDatabase$db
int$id
Returns
RevisionRecord|null

Definition at line 1368 of file RevisionStore.php.

References MediaWiki\Storage\RevisionStore\loadRevisionFromConds().

◆ loadRevisionFromPageId()

MediaWiki\Storage\RevisionStore::loadRevisionFromPageId ( IDatabase  $db,
  $pageid,
  $id = 0 
)

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

If not attached to that page, will return null.

MCR migration note: this replaces Revision::loadFromPageId

Note
direct use is deprecated!
Todo:
remove when unused!
Parameters
IDatabase$db
int$pageid
int$id
Returns
RevisionRecord|null

Definition at line 1387 of file RevisionStore.php.

References MediaWiki\Storage\RevisionStore\loadRevisionFromConds().

◆ loadRevisionFromTimestamp()

MediaWiki\Storage\RevisionStore::loadRevisionFromTimestamp ( IDatabase  $db,
  $title,
  $timestamp 
)

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.

MCR migration note: this replaces Revision::loadFromTimestamp

Note
direct use is deprecated! Use getRevisionFromTimestamp instead!
Todo:
remove when unused!
Parameters
IDatabase$db
Title$title
string$timestamp
Returns
RevisionRecord|null

Definition at line 1447 of file RevisionStore.php.

References $title, MediaWiki\Storage\RevisionStore\loadRevisionFromConds(), and Wikimedia\Rdbms\IDatabase\timestamp().

◆ loadRevisionFromTitle()

MediaWiki\Storage\RevisionStore::loadRevisionFromTitle ( IDatabase  $db,
  $title,
  $id = 0 
)

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

If not attached to that page, will return null.

MCR migration note: this replaces Revision::loadFromTitle

Note
direct use is deprecated!
Todo:
remove when unused!
Parameters
IDatabase$db
Title$title
int$id
Returns
RevisionRecord|null

Definition at line 1413 of file RevisionStore.php.

References $title, and MediaWiki\Storage\RevisionStore\loadRevisionFromConds().

◆ loadSlotContent()

MediaWiki\Storage\RevisionStore::loadSlotContent ( SlotRecord  $slot,
  $blobData = null,
  $blobFlags = null,
  $blobFormat = null,
  $queryFlags = 0 
)
private

Loads a Content object based on a slot row.

This method does not call $slot->getContent(), and may be used as a callback called by $slot->getContent().

MCR migration note: this roughly corresponds to Revision::getContentInternal

Parameters
SlotRecord$slotThe SlotRecord to load content for
string | null$blobDataThe content blob, in the form indicated by $blobFlags
string | null$blobFlagsFlags indicating how $blobData needs to be processed. Use null if no processing should happen. That is in constrast to the empty string, which causes the blob to be decoded according to the configured legacy encoding.
string | null$blobFormatMIME type indicating how $dataBlob is encoded
int$queryFlags
Exceptions
RevisionAccessException
Returns
Content

Definition at line 893 of file RevisionStore.php.

References $e, $handler, MediaWiki\Storage\SlotRecord\getAddress(), ContentHandler\getForModelID(), MediaWiki\Storage\SlotRecord\getModel(), and MediaWiki\Storage\SlotRecord\hasAddress().

Referenced by MediaWiki\Storage\RevisionStore\emulateMainSlot_1_29().

◆ mapArchiveFields()

static MediaWiki\Storage\RevisionStore::mapArchiveFields (   $archiveRow)
staticprivate

Maps fields of the archive row to corresponding revision rows.

Parameters
object$archiveRow
Returns
object a revision row object, corresponding to $archiveRow.

Definition at line 697 of file RevisionStore.php.

References as.

Referenced by MediaWiki\Storage\RevisionStore\emulateMainSlot_1_29().

◆ newMutableRevisionFromArray()

MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray ( array  $fields,
  $queryFlags = 0,
Title  $title = null 
)

Constructs a new MutableRevisionRecord based on the given associative array following the MW1.29 convention for the Revision constructor.

MCR migration note: this replaces Revision::newFromRow

Parameters
array$fields
int$queryFlags
Title | null$title
Returns
MutableRevisionRecord
Exceptions
MWException
RevisionAccessException

Implements MediaWiki\Storage\RevisionFactory.

Definition at line 1217 of file RevisionStore.php.

References $title, MediaWiki\Storage\RevisionStore\emulateMainSlot_1_29(), MediaWiki\Storage\RevisionStore\getTitle(), MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray(), and CommentStoreComment\newUnsavedComment().

◆ newNullRevision()

MediaWiki\Storage\RevisionStore::newNullRevision ( IDatabase  $dbw,
Title  $title,
CommentStoreComment  $comment,
  $minor,
User  $user 
)

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.

MCR migration note: this replaces Revision::newNullRevision

Todo:
Introduce newFromParentRevision(). newNullRevision can then be based on that (or go away).
Parameters
IDatabase$dbw
Title$titleTitle of the page to read from
CommentStoreComment$commentRevisionRecord's summary
bool$minorWhether the revision should be considered as minor
User$userThe user to attribute the revision to
Returns
RevisionRecord|null RevisionRecord or null on error

Definition at line 567 of file RevisionStore.php.

References $title, $user, MediaWiki\Storage\RevisionStore\checkDatabaseWikiId(), MediaWiki\Storage\RevisionStore\emulateMainSlot_1_29(), MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray(), Title\makeTitle(), and Wikimedia\Rdbms\IDatabase\selectRow().

◆ newRevisionFromArchiveRow()

MediaWiki\Storage\RevisionStore::newRevisionFromArchiveRow (   $row,
  $queryFlags = 0,
Title  $title = null,
array  $overrides = [] 
)

Make a fake revision object from an archive table row.

This is queried for permissions or even inserted (as in Special:Undelete)

MCR migration note: this replaces Revision::newFromArchiveRow

Parameters
object$row
int$queryFlags
Title | null$title
array$overridesassociative array with fields of $row to override. This may be used e.g. to force the parent revision ID or page ID. Keys in the array are fields names from the archive table without the 'ar_' prefix, i.e. use 'parent_id' to override ar_parent_id.
Returns
RevisionRecord
Exceptions
MWException

Implements MediaWiki\Storage\RevisionFactory.

Definition at line 1082 of file RevisionStore.php.

References $title, $user, $value, as, DB_REPLICA, MediaWiki\Storage\RevisionStore\emulateMainSlot_1_29(), MediaWiki\Storage\RevisionStore\getDBConnection(), Title\makeTitle(), User\newFromAnyId(), and wfWarn().

◆ newRevisionFromConds()

MediaWiki\Storage\RevisionStore::newRevisionFromConds (   $conditions,
  $flags = 0,
Title  $title = null 
)
private

Given a set of conditions, fetch a revision.

This method should be used if we are pretty sure the revision exists. Unless $flags has READ_LATEST set, this method will first try to find the revision on a replica before hitting the master database.

MCR migration note: this corresponds to Revision::newFromConds

Parameters
array$conditions
int$flags(optional)
Title$title
Returns
RevisionRecord|null

Definition at line 1474 of file RevisionStore.php.

References $rev, $title, DB_MASTER, DB_REPLICA, MediaWiki\Storage\RevisionStore\getDBConnection(), MediaWiki\Storage\RevisionStore\getDBLoadBalancer(), MediaWiki\Storage\RevisionStore\loadRevisionFromConds(), and MediaWiki\Storage\RevisionStore\releaseDBConnection().

Referenced by MediaWiki\Storage\RevisionStore\getRevisionById(), MediaWiki\Storage\RevisionStore\getRevisionByPageId(), MediaWiki\Storage\RevisionStore\getRevisionByTimestamp(), and MediaWiki\Storage\RevisionStore\getRevisionByTitle().

◆ newRevisionFromRow()

MediaWiki\Storage\RevisionStore::newRevisionFromRow (   $row,
  $queryFlags = 0,
Title  $title = null 
)

◆ newRevisionFromRow_1_29()

MediaWiki\Storage\RevisionStore::newRevisionFromRow_1_29 (   $row,
  $queryFlags = 0,
Title  $title = null 
)
private
See also
RevisionFactory::newRevisionFromRow_1_29

MCR migration note: this replaces Revision::newFromRow

Parameters
object$row
int$queryFlags
Title | null$title
Returns
RevisionRecord
Exceptions
MWException
RevisionAccessException

Definition at line 1150 of file RevisionStore.php.

References $title, $user, DB_REPLICA, MediaWiki\Storage\RevisionStore\emulateMainSlot_1_29(), MediaWiki\Storage\RevisionStore\getDBConnection(), MediaWiki\Storage\RevisionStore\getTitle(), User\newFromAnyId(), and wfWarn().

Referenced by MediaWiki\Storage\RevisionStore\newRevisionFromRow().

◆ releaseDBConnection()

◆ setContentHandlerUseDB()

MediaWiki\Storage\RevisionStore::setContentHandlerUseDB (   $contentHandlerUseDB)
Parameters
bool$contentHandlerUseDB

Definition at line 161 of file RevisionStore.php.

References MediaWiki\Storage\RevisionStore\$contentHandlerUseDB.

◆ setLogger()

MediaWiki\Storage\RevisionStore::setLogger ( LoggerInterface  $logger)

Definition at line 140 of file RevisionStore.php.

References MediaWiki\Storage\RevisionStore\$logger.

◆ userWasLastToEdit()

MediaWiki\Storage\RevisionStore::userWasLastToEdit ( IDatabase  $db,
  $pageId,
  $userId,
  $since 
)

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.

MCR migration note: this replaces Revision::userWasLastToEdit

Deprecated:
since 1.31; Can possibly be removed, since the self-conflict suppression logic in EditPage that uses this seems conceptually dubious. Revision::userWasLastToEdit has been deprecated since 1.24.
Parameters
IDatabase$dbThe Database to perform the check on.
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 1926 of file RevisionStore.php.

References $res, $revQuery, Wikimedia\Rdbms\IDatabase\addQuotes(), as, MediaWiki\Storage\RevisionStore\checkDatabaseWikiId(), MediaWiki\Storage\RevisionStore\getQueryInfo(), Wikimedia\Rdbms\IDatabase\select(), and Wikimedia\Rdbms\IDatabase\timestamp().

Member Data Documentation

◆ $actorMigration

ActorMigration MediaWiki\Storage\RevisionStore::$actorMigration
private

Definition at line 104 of file RevisionStore.php.

Referenced by MediaWiki\Storage\RevisionStore\__construct().

◆ $blobStore

SqlBlobStore MediaWiki\Storage\RevisionStore::$blobStore
private

Definition at line 74 of file RevisionStore.php.

Referenced by MediaWiki\Storage\RevisionStore\__construct().

◆ $cache

WANObjectCache MediaWiki\Storage\RevisionStore::$cache
private

Definition at line 94 of file RevisionStore.php.

Referenced by MediaWiki\Storage\RevisionStore\__construct().

◆ $commentStore

CommentStore MediaWiki\Storage\RevisionStore::$commentStore
private

Definition at line 99 of file RevisionStore.php.

Referenced by MediaWiki\Storage\RevisionStore\__construct().

◆ $contentHandlerUseDB

boolean MediaWiki\Storage\RevisionStore::$contentHandlerUseDB = true
private

◆ $loadBalancer

LoadBalancer MediaWiki\Storage\RevisionStore::$loadBalancer
private

◆ $logger

LoggerInterface MediaWiki\Storage\RevisionStore::$logger
private

Definition at line 109 of file RevisionStore.php.

Referenced by MediaWiki\Storage\RevisionStore\setLogger().

◆ $wikiId

bool string MediaWiki\Storage\RevisionStore::$wikiId
private

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