MediaWiki REL1_32
MediaWiki\Revision\RevisionStore Class Reference

Service for looking up page revisions. More...

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

Public Member Functions

 __construct (ILoadBalancer $loadBalancer, SqlBlobStore $blobStore, WANObjectCache $cache, CommentStore $commentStore, NameTableStore $contentModelStore, NameTableStore $slotRoleStore, $mcrMigrationStage, ActorMigration $actorMigration, $wikiId=false)
 
 countRevisionsByPageId (IDatabase $db, $id)
 Get count of revisions per page...not very efficient.
 
 countRevisionsByTitle (IDatabase $db, $title)
 Get count of revisions per page...not very efficient.
 
 getArchiveQueryInfo ()
 Return the tables, fields, and join conditions to be selected to create a new RevisionArchiveRecord object.
 
 getContentHandlerUseDB ()
 
 getKnownCurrentRevision (Title $title, $revId)
 Load a revision based on a known page ID and current revision ID from the DB.
 
 getNextRevision (RevisionRecord $rev, Title $title=null)
 Get next revision for this title.
 
 getPreviousRevision (RevisionRecord $rev, Title $title=null)
 Get previous revision for this title.
 
 getQueryInfo ( $options=[])
 Return the tables, fields, and join conditions to be selected to create a new RevisionStoreRecord object.
 
 getRcIdIfUnpatrolled (RevisionRecord $rev)
 MCR migration note: this replaces Revision::isUnpatrolled.
 
 getRecentChange (RevisionRecord $rev, $flags=0)
 Get the RC object belonging to the current revision, if there's one.
 
 getRevisionById ( $id, $flags=0)
 Load a page revision from a given revision ID number.
 
 getRevisionByPageId ( $pageId, $revId=0, $flags=0)
 Load either the current, or a specified, revision that's attached to a given page ID.
 
 getRevisionByTimestamp ( $title, $timestamp)
 Load the revision for the given title with the given timestamp.
 
 getRevisionByTitle (LinkTarget $linkTarget, $revId=0, $flags=0)
 Load either the current, or a specified, revision that's attached to a given link target.
 
 getRevisionSizes (array $revIds)
 Do a batched query for the sizes of a set of revisions.
 
 getSlotsQueryInfo ( $options=[])
 Return the tables, fields, and join conditions to be selected to create a new SlotRecord.
 
 getTimestampFromId ( $title, $id, $flags=0)
 Get rev_timestamp from rev_id, without loading the rest of the row.
 
 getTitle ( $pageId, $revId, $queryFlags=self::READ_NORMAL)
 Determines the page Title based on the available information.
 
 insertRevisionOn (RevisionRecord $rev, IDatabase $dbw)
 Insert a new revision into the database, returning the new revision record on success and dies horribly on failure.
 
 isReadOnly ()
 
 listRevisionSizes (IDatabase $db, array $revIds)
 Do a batched query for the sizes of a set of revisions.
 
 loadRevisionFromId (IDatabase $db, $id)
 Load a page revision from a given revision ID number.
 
 loadRevisionFromPageId (IDatabase $db, $pageid, $id=0)
 Load either the current, or a specified, revision that's attached to a given page.
 
 loadRevisionFromTimestamp (IDatabase $db, $title, $timestamp)
 Load the revision for the given title with the given timestamp.
 
 loadRevisionFromTitle (IDatabase $db, $title, $id=0)
 Load either the current, or a specified, revision that's attached to a given page.
 
 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.
 
 newNullRevision (IDatabase $dbw, Title $title, CommentStoreComment $comment, $minor, User $user)
 Create a new null-revision for insertion into a page's history.
 
 newRevisionFromArchiveRow ( $row, $queryFlags=0, Title $title=null, array $overrides=[])
 Make a fake revision object from an archive table row.
 
 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.
 

Public Attributes

const ROW_CACHE_KEY = 'revision-row-1.29'
 
- Public Attributes inherited from IDBAccessObject
const READ_LOCKING = self::READ_LATEST | 2
 Constants for object loading bitfield flags (higher => higher QoS)
 
const READ_NONE = -1
 

Private Member Functions

 assertCrossWikiContentLoadingIsSafe ()
 Throws a RevisionAccessException if this RevisionStore is configured for cross-wiki loading and still reading from the old DB schema.
 
 checkContent (Content $content, Title $title)
 MCR migration note: this corresponds to Revision::checkContentModel.
 
 checkDatabaseWikiId (IDatabase $db)
 Throws an exception if the given database connection does not belong to the wiki this RevisionStore is bound to.
 
 emulateContentId ( $textId)
 Provides a content ID to use with emulated SlotRecords in SCHEMA_COMPAT_OLD mode, based on the revision's text ID (rev_text_id or ar_text_id, respectively).
 
 emulateMainSlot_1_29 ( $row, $queryFlags, Title $title)
 Constructs a RevisionRecord for the revisions main slot, based on the MW1.29 schema.
 
 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.
 
 findSlotContentId (IDatabase $db, $revId, $role)
 Finds the ID of a content row for a given revision and slot role.
 
 getBaseRevisionRow (IDatabase $dbw, RevisionRecord $rev, Title $title, $parentId)
 
 getDBConnection ( $mode)
 
 getDBConnectionRef ( $mode)
 
 getDBConnectionRefForQueryFlags ( $queryFlags)
 
 getDBLoadBalancer ()
 
 getPreviousRevisionId (IDatabase $db, RevisionRecord $rev)
 Get previous revision Id for this page_id This is used to populate rev_parent_id on save.
 
 getRevisionRowCacheKey (IDatabase $db, $pageId, $revId)
 Get a cache key for use with a row as selected with getQueryInfo( [ 'page', 'user' ] ) Caching rows without 'page' or 'user' could lead to issues.
 
 hasMcrSchemaFlags ( $flags)
 
 initializeMutableRevisionFromArray (MutableRevisionRecord $record, array $fields)
 
 insertContentRowOn (SlotRecord $slot, IDatabase $dbw, $blobAddress)
 
 insertIpChangesRow (IDatabase $dbw, User $user, RevisionRecord $rev, $revisionId)
 Insert IP revision into ip_changes for use when querying for a range.
 
 insertRevisionInternal (RevisionRecord $rev, IDatabase $dbw, User $user, CommentStoreComment $comment, Title $title, $pageId, $parentId)
 
 insertRevisionRowOn (IDatabase $dbw, RevisionRecord $rev, Title $title, $parentId)
 
 insertSlotOn (IDatabase $dbw, $revisionId, SlotRecord $protoSlot, Title $title, array $blobHints=[])
 
 insertSlotRowOn (SlotRecord $slot, IDatabase $dbw, $revisionId, $contentId)
 
 loadRevisionFromConds (IDatabase $db, $conditions, $flags=0, Title $title=null)
 Given a set of conditions, fetch a revision from the given database connection.
 
 loadSlotContent (SlotRecord $slot, $blobData=null, $blobFlags=null, $blobFormat=null, $queryFlags=0)
 Loads a Content object based on a slot row.
 
 loadSlotRecords ( $revId, $queryFlags)
 
 newRevisionFromConds ( $conditions, $flags=0, Title $title=null)
 Given a set of conditions, fetch a revision.
 
 newRevisionSlots ( $revId, $revisionRow, $queryFlags, Title $title)
 Factory method for RevisionSlots.
 
 releaseDBConnection (IDatabase $connection)
 
 storeContentBlob (SlotRecord $slot, Title $title, array $blobHints=[])
 
 updateRevisionTextId (IDatabase $dbw, $revisionId, &$blobAddress)
 

Static Private Member Functions

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

Private Attributes

ActorMigration $actorMigration
 
SqlBlobStore $blobStore
 
WANObjectCache $cache
 
CommentStore $commentStore
 
boolean $contentHandlerUseDB = true
 
NameTableStore $contentModelStore
 
ILoadBalancer $loadBalancer
 
LoggerInterface $logger
 
int $mcrMigrationStage
 An appropriate combination of SCHEMA_COMPAT_XXX flags.
 
NameTableStore $slotRoleStore
 
bool string $wikiId
 

Detailed Description

Service for looking up page revisions.

Since
1.31
1.32 Renamed from MediaWiki\Storage\RevisionStore
Note
This was written to act as a drop-in replacement for the corresponding static methods in Revision.

Definition at line 76 of file RevisionStore.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Revision\RevisionStore::__construct ( ILoadBalancer $loadBalancer,
SqlBlobStore $blobStore,
WANObjectCache $cache,
CommentStore $commentStore,
NameTableStore $contentModelStore,
NameTableStore $slotRoleStore,
$mcrMigrationStage,
ActorMigration $actorMigration,
$wikiId = false )
Todo
$blobStore should be allowed to be any BlobStore!
Parameters
ILoadBalancer$loadBalancer
SqlBlobStore$blobStore
WANObjectCache$cacheA cache for caching revision rows. This can be the local wiki's default instance even if $wikiId refers to a different wiki, since makeGlobalKey() is used to constructed a key that allows cached revision rows from the same database to be re-used between wikis. For example, enwiki and frwiki will use the same cache keys for revision rows from the wikidatawiki database, regardless of the cache's default key space.
CommentStore$commentStore
NameTableStore$contentModelStore
NameTableStore$slotRoleStore
int$mcrMigrationStageAn appropriate combination of SCHEMA_COMPAT_XXX flags
ActorMigration$actorMigration
bool | string$wikiId
Exceptions
MWExceptionif $mcrMigrationStage or $wikiId is invalid.

Definition at line 155 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\$actorMigration, MediaWiki\Revision\RevisionStore\$blobStore, MediaWiki\Revision\RevisionStore\$cache, MediaWiki\Revision\RevisionStore\$commentStore, MediaWiki\Revision\RevisionStore\$contentModelStore, MediaWiki\Revision\RevisionStore\$loadBalancer, MediaWiki\Revision\RevisionStore\$mcrMigrationStage, MediaWiki\Revision\RevisionStore\$slotRoleStore, MediaWiki\Revision\RevisionStore\$wikiId, cache, SCHEMA_COMPAT_READ_BOTH, SCHEMA_COMPAT_READ_NEW, SCHEMA_COMPAT_READ_OLD, SCHEMA_COMPAT_WRITE_BOTH, SCHEMA_COMPAT_WRITE_NEW, and SCHEMA_COMPAT_WRITE_OLD.

Member Function Documentation

◆ assertCrossWikiContentLoadingIsSafe()

MediaWiki\Revision\RevisionStore::assertCrossWikiContentLoadingIsSafe ( )
private

Throws a RevisionAccessException if this RevisionStore is configured for cross-wiki loading and still reading from the old DB schema.

Exceptions
RevisionAccessException

Definition at line 223 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\hasMcrSchemaFlags(), and SCHEMA_COMPAT_READ_OLD.

Referenced by MediaWiki\Revision\RevisionStore\checkContent(), MediaWiki\Revision\RevisionStore\emulateMainSlot_1_29(), and MediaWiki\Revision\RevisionStore\getBaseRevisionRow().

◆ checkContent()

MediaWiki\Revision\RevisionStore::checkContent ( Content $content,
Title $title )
private

MCR migration note: this corresponds to Revision::checkContentModel.

Parameters
Content$content
Title$title
Exceptions
MWException
MWUnknownContentModelException

Definition at line 989 of file RevisionStore.php.

References $content, $handler, and MediaWiki\Revision\RevisionStore\assertCrossWikiContentLoadingIsSafe().

Referenced by MediaWiki\Revision\RevisionStore\storeContentBlob().

◆ checkDatabaseWikiId()

◆ countRevisionsByPageId()

MediaWiki\Revision\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 2625 of file RevisionStore.php.

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

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

◆ countRevisionsByTitle()

MediaWiki\Revision\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 2648 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\countRevisionsByPageId().

◆ emulateContentId()

MediaWiki\Revision\RevisionStore::emulateContentId ( $textId)
private

Provides a content ID to use with emulated SlotRecords in SCHEMA_COMPAT_OLD mode, based on the revision's text ID (rev_text_id or ar_text_id, respectively).

Note that in SCHEMA_COMPAT_WRITE_BOTH, a callback to findSlotContentId() should be used instead, since in that mode, some revision rows may already have a real content ID, while other's don't - and for the ones that don't, we should indicate that it is missing and cause SlotRecords::hasContentId() to return false.

Parameters
int$textId
Returns
int The emulated content ID

Definition at line 1401 of file RevisionStore.php.

Referenced by MediaWiki\Revision\RevisionStore\emulateMainSlot_1_29(), and MediaWiki\Revision\RevisionStore\insertSlotOn().

◆ emulateMainSlot_1_29()

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

◆ failOnEmpty()

MediaWiki\Revision\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 418 of file RevisionStore.php.

References $value.

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

◆ failOnNull()

MediaWiki\Revision\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 401 of file RevisionStore.php.

References $value.

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

◆ fetchRevisionRowFromConds()

MediaWiki\Revision\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 2180 of file RevisionStore.php.

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

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

◆ findSlotContentId()

MediaWiki\Revision\RevisionStore::findSlotContentId ( IDatabase $db,
$revId,
$role )
private

Finds the ID of a content row for a given revision and slot role.

This can be used to re-use content rows even while the content ID is still missing from SlotRecords, when writing to both the old and the new schema during MCR schema migration.

Todo
remove after MCR schema migration is complete.
Parameters
IDatabase$db
int$revId
string$role
Returns
int|null

Definition at line 2212 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\hasMcrSchemaFlags(), SCHEMA_COMPAT_WRITE_NEW, and Wikimedia\Rdbms\IDatabase\selectField().

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

◆ getArchiveQueryInfo()

MediaWiki\Revision\RevisionStore::getArchiveQueryInfo ( )

Return the tables, fields, and join conditions to be selected to create a new RevisionArchiveRecord 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 2439 of file RevisionStore.php.

References $ret, MediaWiki\Revision\RevisionStore\hasMcrSchemaFlags(), and SCHEMA_COMPAT_READ_OLD.

◆ getBaseRevisionRow()

MediaWiki\Revision\RevisionStore::getBaseRevisionRow ( IDatabase $dbw,
RevisionRecord $rev,
Title $title,
$parentId )
private

◆ getContentHandlerUseDB()

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

Definition at line 245 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\$contentHandlerUseDB.

◆ getDBConnection()

MediaWiki\Revision\RevisionStore::getDBConnection ( $mode)
private

◆ getDBConnectionRef()

◆ getDBConnectionRefForQueryFlags()

◆ getDBLoadBalancer()

◆ getKnownCurrentRevision()

MediaWiki\Revision\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\Revision\RevisionLookup.

Definition at line 2716 of file RevisionStore.php.

References array(), cache, DB_REPLICA, MediaWiki\Revision\RevisionStore\fetchRevisionRowFromConds(), MediaWiki\Revision\RevisionStore\getDBConnectionRef(), MediaWiki\Revision\RevisionStore\getRevisionRowCacheKey(), MediaWiki\Revision\RevisionStore\newRevisionFromRow(), and wfWarn().

◆ getNextRevision()

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

Get next revision for this title.

MCR migration note: this replaces Revision::getNext

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

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 2550 of file RevisionStore.php.

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

◆ getPreviousRevision()

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

Get previous revision for this title.

MCR migration note: this replaces Revision::getPrevious

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

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 2529 of file RevisionStore.php.

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

◆ getPreviousRevisionId()

MediaWiki\Revision\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 2572 of file RevisionStore.php.

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

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

◆ getQueryInfo()

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

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

MCR migration note: this replaces Revision::getQueryInfo

If the format of fields returned changes in any way then the cache key provided by self::getRevisionRowCacheKey should be updated.

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. This option is deprecated in MW 1.32 when the MCR migration flag SCHEMA_COMPAT_WRITE_NEW is set, and disallowed when SCHEMA_COMPAT_READ_OLD is not set.
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 2257 of file RevisionStore.php.

References $options, $ret, MediaWiki\Revision\RevisionStore\hasMcrSchemaFlags(), SCHEMA_COMPAT_READ_OLD, and SCHEMA_COMPAT_WRITE_OLD.

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

◆ getRcIdIfUnpatrolled()

MediaWiki\Revision\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 1123 of file RevisionStore.php.

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

◆ getRecentChange()

MediaWiki\Revision\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 1145 of file RevisionStore.php.

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

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

◆ getRevisionById()

MediaWiki\Revision\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\Revision\RevisionLookup.

Definition at line 1484 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\newRevisionFromConds().

◆ getRevisionByPageId()

MediaWiki\Revision\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\Revision\RevisionLookup.

Definition at line 1548 of file RevisionStore.php.

References $rev, MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags(), MediaWiki\Revision\RevisionStore\loadRevisionFromConds(), and MediaWiki\Revision\RevisionStore\newRevisionFromConds().

◆ getRevisionByTimestamp()

MediaWiki\Revision\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 1584 of file RevisionStore.php.

References DB_REPLICA, MediaWiki\Revision\RevisionStore\getDBConnection(), and MediaWiki\Revision\RevisionStore\newRevisionFromConds().

◆ getRevisionByTitle()

MediaWiki\Revision\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\Revision\RevisionLookup.

Definition at line 1504 of file RevisionStore.php.

References $rev, MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), MediaWiki\Revision\RevisionStore\loadRevisionFromConds(), and MediaWiki\Revision\RevisionStore\newRevisionFromConds().

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

◆ getRevisionRowCacheKey()

MediaWiki\Revision\RevisionStore::getRevisionRowCacheKey ( IDatabase $db,
$pageId,
$revId )
private

Get a cache key for use with a row as selected with getQueryInfo( [ 'page', 'user' ] ) Caching rows without 'page' or 'user' could lead to issues.

If the format of the rows returned by the query provided by getQueryInfo changes the cache key should be updated to avoid conflicts.

Parameters
IDatabase$db
int$pageId
int$revId
Returns
string

Definition at line 2774 of file RevisionStore.php.

References cache, and Wikimedia\Rdbms\IDatabase\getDomainID().

Referenced by MediaWiki\Revision\RevisionStore\getKnownCurrentRevision().

◆ getRevisionSizes()

MediaWiki\Revision\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 2481 of file RevisionStore.php.

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

◆ getSlotsQueryInfo()

MediaWiki\Revision\RevisionStore::getSlotsQueryInfo ( $options = [])

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

Since
1.32
Parameters
array$optionsAny combination of the following strings
  • 'content': Join with the content table, and select content meta-data fields
  • 'model': Join with the content_models table, and select the model_name field. Only applicable if 'content' is also set.
  • 'role': Join with the slot_roles table, and select the role_name field
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 2357 of file RevisionStore.php.

References $options, $ret, DB_REPLICA, MediaWiki\Revision\RevisionStore\getDBConnectionRef(), MediaWiki\Revision\RevisionStore\hasMcrSchemaFlags(), MediaWiki\Revision\SlotRecord\MAIN, and SCHEMA_COMPAT_READ_OLD.

Referenced by MediaWiki\Revision\RevisionStore\loadSlotRecords().

◆ getTimestampFromId()

MediaWiki\Revision\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 2606 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags(), and wfTimestamp().

◆ getTitle()

MediaWiki\Revision\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 326 of file RevisionStore.php.

References $dbr, $title, DB_MASTER, false, MediaWiki\Revision\RevisionStore\getDBConnectionRef(), DBAccessObjectUtils\getDBOptions(), MediaWiki\Revision\RevisionStore\getTitle(), DBAccessObjectUtils\hasFlags(), list, and wfBacktrace().

Referenced by MediaWiki\Revision\RevisionStore\getNextRevision(), MediaWiki\Revision\RevisionStore\getPreviousRevision(), MediaWiki\Revision\RevisionStore\getTitle(), MediaWiki\Revision\RevisionStore\newMutableRevisionFromArray(), and MediaWiki\Revision\RevisionStore\newRevisionFromRow().

◆ hasMcrSchemaFlags()

◆ initializeMutableRevisionFromArray()

MediaWiki\Revision\RevisionStore::initializeMutableRevisionFromArray ( MutableRevisionRecord $record,
array $fields )
private
Parameters
MutableRevisionRecord$record
array$fields

Definition at line 1896 of file RevisionStore.php.

References User\newFromAnyId(), and wfTimestampNow().

Referenced by MediaWiki\Revision\RevisionStore\newMutableRevisionFromArray().

◆ insertContentRowOn()

MediaWiki\Revision\RevisionStore::insertContentRowOn ( SlotRecord $slot,
IDatabase $dbw,
$blobAddress )
private

◆ insertIpChangesRow()

MediaWiki\Revision\RevisionStore::insertIpChangesRow ( IDatabase $dbw,
User $user,
RevisionRecord $rev,
$revisionId )
private

Insert IP revision into ip_changes for use when querying for a range.

Parameters
IDatabase$dbw
User$user
RevisionRecord$rev
int$revisionId

Definition at line 722 of file RevisionStore.php.

References $rev, Wikimedia\Rdbms\IDatabase\insert(), and Wikimedia\Rdbms\IDatabase\timestamp().

Referenced by MediaWiki\Revision\RevisionStore\insertRevisionInternal().

◆ insertRevisionInternal()

◆ insertRevisionOn()

◆ insertRevisionRowOn()

◆ insertSlotOn()

◆ insertSlotRowOn()

MediaWiki\Revision\RevisionStore::insertSlotRowOn ( SlotRecord $slot,
IDatabase $dbw,
$revisionId,
$contentId )
private

◆ isReadOnly()

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

Definition at line 238 of file RevisionStore.php.

◆ listRevisionSizes()

MediaWiki\Revision\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 2497 of file RevisionStore.php.

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

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

◆ loadRevisionFromConds()

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

◆ loadRevisionFromId()

MediaWiki\Revision\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 1976 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\loadRevisionFromConds().

◆ loadRevisionFromPageId()

MediaWiki\Revision\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 1995 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\loadRevisionFromConds().

◆ loadRevisionFromTimestamp()

MediaWiki\Revision\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 2055 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\loadRevisionFromConds(), and Wikimedia\Rdbms\IDatabase\timestamp().

◆ loadRevisionFromTitle()

MediaWiki\Revision\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 2021 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\loadRevisionFromConds().

◆ loadSlotContent()

MediaWiki\Revision\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 1427 of file RevisionStore.php.

References $content, $e, $handler, MediaWiki\Revision\SlotRecord\getAddress(), MediaWiki\Revision\SlotRecord\getModel(), and MediaWiki\Revision\SlotRecord\hasAddress().

Referenced by MediaWiki\Revision\RevisionStore\emulateMainSlot_1_29(), and MediaWiki\Revision\RevisionStore\loadSlotRecords().

◆ loadSlotRecords()

MediaWiki\Revision\RevisionStore::loadSlotRecords ( $revId,
$queryFlags )
private

◆ mapArchiveFields()

static MediaWiki\Revision\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 1182 of file RevisionStore.php.

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

◆ newMutableRevisionFromArray()

MediaWiki\Revision\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\Revision\RevisionFactory.

Definition at line 1811 of file RevisionStore.php.

References $content, MediaWiki\Revision\RevisionStore\emulateMainSlot_1_29(), MediaWiki\Revision\RevisionStore\getTitle(), MediaWiki\Revision\RevisionStore\hasMcrSchemaFlags(), MediaWiki\Revision\RevisionStore\initializeMutableRevisionFromArray(), and SCHEMA_COMPAT_READ_OLD.

◆ newNullRevision()

MediaWiki\Revision\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.

Note
This method grabs a FOR UPDATE lock on the relevant row of the page table, to prevent a new revision from being inserted before the null revision has been written to the database.

MCR migration note: this replaces Revision::newNullRevision

Todo
Introduce newFromParentRevision(). newNullRevision can then be based on that (or go away).
Parameters
IDatabase$dbwused for obtaining the lock on the page table row
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 1059 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\checkDatabaseWikiId(), MediaWiki\Revision\RevisionStore\loadRevisionFromConds(), MediaWiki\Revision\MutableRevisionRecord\newFromParentRevision(), Wikimedia\Rdbms\IDatabase\selectField(), and wfTimestampNow().

◆ newRevisionFromArchiveRow()

MediaWiki\Revision\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\Revision\RevisionFactory.

Definition at line 1695 of file RevisionStore.php.

References $value, MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags(), User\newFromAnyId(), MediaWiki\Revision\RevisionStore\newRevisionSlots(), and wfWarn().

◆ newRevisionFromConds()

MediaWiki\Revision\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 | null$title
Returns
RevisionRecord|null

Definition at line 2082 of file RevisionStore.php.

References $rev, DB_MASTER, MediaWiki\Revision\RevisionStore\getDBConnection(), MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags(), MediaWiki\Revision\RevisionStore\getDBLoadBalancer(), MediaWiki\Revision\RevisionStore\loadRevisionFromConds(), and MediaWiki\Revision\RevisionStore\releaseDBConnection().

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

◆ newRevisionFromRow()

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

◆ newRevisionSlots()

MediaWiki\Revision\RevisionStore::newRevisionSlots ( $revId,
$revisionRow,
$queryFlags,
Title $title )
private

Factory method for RevisionSlots.

Note
If other code has a need to construct RevisionSlots objects, this should be made public, since RevisionSlots instances should not be constructed directly.
Parameters
int$revId
object$revisionRow
int$queryFlags
Title$title
Returns
RevisionSlots
Exceptions
MWException

Definition at line 1657 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\emulateMainSlot_1_29(), MediaWiki\Revision\RevisionStore\hasMcrSchemaFlags(), MediaWiki\Revision\RevisionStore\loadSlotRecords(), MediaWiki\Revision\SlotRecord\MAIN, SCHEMA_COMPAT_READ_NEW, and use.

Referenced by MediaWiki\Revision\RevisionStore\newRevisionFromArchiveRow(), and MediaWiki\Revision\RevisionStore\newRevisionFromRow().

◆ releaseDBConnection()

MediaWiki\Revision\RevisionStore::releaseDBConnection ( IDatabase $connection)
private

◆ setContentHandlerUseDB()

MediaWiki\Revision\RevisionStore::setContentHandlerUseDB ( $contentHandlerUseDB)

◆ setLogger()

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

Definition at line 231 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\$logger.

◆ storeContentBlob()

◆ updateRevisionTextId()

MediaWiki\Revision\RevisionStore::updateRevisionTextId ( IDatabase $dbw,
$revisionId,
& $blobAddress )
private
Parameters
IDatabase$dbw
int$revisionId
string&$blobAddress(may change!)
Returns
int the text row id

Definition at line 640 of file RevisionStore.php.

References Wikimedia\Rdbms\IDatabase\update().

Referenced by MediaWiki\Revision\RevisionStore\insertRevisionInternal(), and MediaWiki\Revision\RevisionStore\insertSlotOn().

◆ userWasLastToEdit()

MediaWiki\Revision\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 2674 of file RevisionStore.php.

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

Member Data Documentation

◆ $actorMigration

ActorMigration MediaWiki\Revision\RevisionStore::$actorMigration
private

Definition at line 115 of file RevisionStore.php.

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

◆ $blobStore

SqlBlobStore MediaWiki\Revision\RevisionStore::$blobStore
private

Definition at line 84 of file RevisionStore.php.

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

◆ $cache

WANObjectCache MediaWiki\Revision\RevisionStore::$cache
private

Definition at line 105 of file RevisionStore.php.

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

◆ $commentStore

CommentStore MediaWiki\Revision\RevisionStore::$commentStore
private

Definition at line 110 of file RevisionStore.php.

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

◆ $contentHandlerUseDB

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

◆ $contentModelStore

NameTableStore MediaWiki\Revision\RevisionStore::$contentModelStore
private

Definition at line 125 of file RevisionStore.php.

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

◆ $loadBalancer

ILoadBalancer MediaWiki\Revision\RevisionStore::$loadBalancer
private

◆ $logger

LoggerInterface MediaWiki\Revision\RevisionStore::$logger
private

Definition at line 120 of file RevisionStore.php.

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

◆ $mcrMigrationStage

int MediaWiki\Revision\RevisionStore::$mcrMigrationStage
private

An appropriate combination of SCHEMA_COMPAT_XXX flags.

Definition at line 133 of file RevisionStore.php.

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

◆ $slotRoleStore

NameTableStore MediaWiki\Revision\RevisionStore::$slotRoleStore
private

Definition at line 130 of file RevisionStore.php.

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

◆ $wikiId

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

◆ ROW_CACHE_KEY

const MediaWiki\Revision\RevisionStore::ROW_CACHE_KEY = 'revision-row-1.29'

Definition at line 79 of file RevisionStore.php.


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