MediaWiki  master
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, SlotRoleRegistry $slotRoleRegistry, ActorMigration $actorMigration, ActorStore $actorStore, IContentHandlerFactory $contentHandlerFactory, PageStore $pageStore, TitleFactory $titleFactory, HookContainer $hookContainer, $wikiId=WikiAwareEntity::LOCAL)
 
 countAuthorsBetween ( $pageId, RevisionRecord $old=null, RevisionRecord $new=null, Authority $performer=null, $max=null, $options=[])
 Get the number of authors between the given revisions. More...
 
 countRevisionsBetween ( $pageId, RevisionRecord $old=null, RevisionRecord $new=null, $max=null, $options=[])
 Get the number of revisions between the given revisions. More...
 
 countRevisionsByPageId (IDatabase $db, $id)
 Get count of revisions per page...not very efficient. More...
 
 countRevisionsByTitle (IDatabase $db, PageIdentity $page)
 Get count of revisions per page...not very efficient. More...
 
 findIdenticalRevision (RevisionRecord $revision, int $searchLimit)
 Tries to find a revision identical to $revision in $searchLimit most recent revisions of this page. More...
 
 getArchiveQueryInfo ()
 Return the tables, fields, and join conditions to be selected to create a new RevisionArchiveRecord object. More...
 
 getAuthorsBetween ( $pageId, RevisionRecord $old=null, RevisionRecord $new=null, Authority $performer=null, $max=null, $options=[])
 Get the authors between the given revisions or revisions. More...
 
 getContentBlobsForBatch ( $rowsOrIds, $slots=null, $queryFlags=0)
 Gets raw (serialized) content blobs for the given set of revisions. More...
 
 getFirstRevision ( $page, int $flags=IDBAccessObject::READ_NORMAL)
 Get the first revision of a given page. More...
 
 getKnownCurrentRevision (PageIdentity $page, $revId=0)
 Load a revision based on a known page ID and current revision ID from the DB. More...
 
 getNextRevision (RevisionRecord $rev, $flags=self::READ_NORMAL)
 Get the revision after $rev in the page's history, if any. More...
 
 getPreviousRevision (RevisionRecord $rev, $flags=self::READ_NORMAL)
 Get the revision before $rev in the page's history, if any. More...
 
 getQueryInfo ( $options=[])
 Return the tables, fields, and join conditions to be selected to create a new RevisionStoreRecord object. More...
 
 getRcIdIfUnpatrolled (RevisionRecord $rev)
 MCR migration note: this replaced 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, PageIdentity $page=null)
 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 ( $page, string $timestamp, int $flags=IDBAccessObject::READ_NORMAL)
 Load the revision for the given title with the given timestamp. More...
 
 getRevisionByTitle ( $page, $revId=0, $flags=0)
 Load either the current, or a specified, revision that's attached to a given link target. More...
 
 getRevisionIdsBetween (int $pageId, RevisionRecord $old=null, RevisionRecord $new=null, ?int $max=null, $options=[], ?string $order=null, int $flags=IDBAccessObject::READ_NORMAL)
 Get IDs of revisions between the given revisions. More...
 
 getRevisionSizes (array $revIds)
 Do a batched query for the sizes of a set of revisions. More...
 
 getSlotsQueryInfo ( $options=[])
 Return the tables, fields, and join conditions to be selected to create a new SlotRecord. More...
 
 getTimestampFromId ( $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...
 
 getWikiId ()
 Get the ID of the wiki this revision belongs to. 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 ()
 
 isRevisionRow ( $row, string $table='')
 Determine whether the parameter is a row containing all the fields that RevisionStore needs to create a RevisionRecord from the row. More...
 
 newNullRevision (IDatabase $dbw, PageIdentity $page, CommentStoreComment $comment, $minor, UserIdentity $user)
 Create a new null-revision for insertion into a page's history. More...
 
 newRevisionFromArchiveRow ( $row, $queryFlags=0, PageIdentity $page=null, array $overrides=[])
 Make a fake RevisionRecord object from an archive table row. More...
 
 newRevisionFromArchiveRowAndSlots (stdClass $row, $slots, int $queryFlags=0, ?PageIdentity $page=null, array $overrides=[])
 
 newRevisionFromRow ( $row, $queryFlags=0, PageIdentity $page=null, $fromCache=false)
 
 newRevisionFromRowAndSlots (stdClass $row, $slots, int $queryFlags=0, ?PageIdentity $page=null, bool $fromCache=false)
 
 newRevisionsFromBatch ( $rows, array $options=[], $queryFlags=0, PageIdentity $page=null)
 Construct a RevisionRecord instance for each row in $rows, and return them as an associative array indexed by revision ID. More...
 
 setLogger (LoggerInterface $logger)
 
 updateSlotsOn (RevisionRecord $revision, RevisionSlotsUpdate $revisionSlotsUpdate, IDatabase $dbw)
 Update derived slots in an existing revision into the database, returning the modified slots on success. More...
 
 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...
 
- Public Member Functions inherited from MediaWiki\Revision\RevisionFactory
 newRevisionFromRow ( $row, $queryFlags=self::READ_NORMAL, PageIdentity $page=null)
 Constructs a RevisionRecord given a database row and content slots. More...
 

Public Attributes

const INCLUDE_BOTH = 'include_both'
 
const INCLUDE_NEW = 'include_new'
 
const INCLUDE_OLD = 'include_old'
 
const ORDER_NEWEST_TO_OLDEST = 'DESC'
 
const ORDER_OLDEST_TO_NEWEST = 'ASC'
 
const ROW_CACHE_KEY = 'revision-row-1.29'
 
- Public Attributes inherited from IDBAccessObject
const READ_NONE = -1
 Constants for object loading bitfield flags (higher => higher QoS) More...
 

Private Member Functions

 assertRevisionParameter ( $paramName, $pageId, RevisionRecord $rev=null)
 Asserts that if revision is provided, it's saved and belongs to the page with provided pageId. More...
 
 checkContent (Content $content, PageIdentity $page, string $role)
 MCR migration note: this corresponded to Revision::checkContentModel. More...
 
 checkDatabaseDomain (IDatabase $db)
 Throws an exception if the given database connection does not belong to the wiki this RevisionStore is bound to. More...
 
 constructSlotRecords ( $revId, $slotRows, $queryFlags, PageIdentity $page, $slotContents=null)
 Factory method for SlotRecords based on known slot rows. More...
 
 ensureRevisionRowMatchesPage ( $row, PageIdentity $page, $context=[])
 Check that the given row matches the given Title object. More...
 
 failOnEmpty ( $value, $name)
 
 failOnNull ( $value, $name)
 
 fetchRevisionRowFromConds (IDatabase $db, array $conditions, int $flags=IDBAccessObject::READ_NORMAL, array $options=[])
 Given a set of conditions, return a row with the fields necessary to build RevisionRecord objects. More...
 
 getBaseRevisionRow (IDatabase $dbw, RevisionRecord $rev, $parentId)
 
 getDBConnectionRef ( $mode, $groups=[])
 
 getDBConnectionRefForQueryFlags ( $queryFlags)
 
 getDBLoadBalancer ()
 
 getPage (?int $pageId, ?int $revId, int $queryFlags=self::READ_NORMAL)
 Determines the page based on the available information. More...
 
 getPreviousRevisionId (IDatabase $db, RevisionRecord $rev)
 Get previous revision Id for this page_id This is used to populate rev_parent_id on save. More...
 
 getRelativeRevision (RevisionRecord $rev, $flags, $dir)
 Implementation of getPreviousRevision and getNextRevision. More...
 
 getRevisionLimitConditions (IDatabase $dbr, RevisionRecord $old=null, RevisionRecord $new=null, $options=[])
 Converts revision limits to query conditions. More...
 
 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. More...
 
 getSlotRowsForBatch ( $rowsOrIds, array $options=[], $queryFlags=0)
 Gets the slot rows associated with a batch of revisions. More...
 
 insertContentRowOn (SlotRecord $slot, IDatabase $dbw, $blobAddress)
 
 insertIpChangesRow (IDatabase $dbw, UserIdentity $user, RevisionRecord $rev, $revisionId)
 Insert IP revision into ip_changes for use when querying for a range. More...
 
 insertRevisionInternal (RevisionRecord $rev, IDatabase $dbw, UserIdentity $user, CommentStoreComment $comment, PageIdentity $page, $pageId, $parentId)
 
 insertRevisionRowOn (IDatabase $dbw, RevisionRecord $rev, $parentId)
 
 insertSlotOn (IDatabase $dbw, $revisionId, SlotRecord $protoSlot, PageIdentity $page, array $blobHints=[])
 
 insertSlotRowOn (SlotRecord $slot, IDatabase $dbw, $revisionId, $contentId)
 
 loadRevisionFromConds (IDatabase $db, array $conditions, int $flags=IDBAccessObject::READ_NORMAL, PageIdentity $page=null, array $options=[])
 Given a set of conditions, fetch a revision from the given database connection. More...
 
 loadSlotContent (SlotRecord $slot, ?string $blobData=null, ?string $blobFlags=null, ?string $blobFormat=null, int $queryFlags=0)
 Loads a Content object based on a slot row. More...
 
 loadSlotRecords ( $revId, $queryFlags, PageIdentity $page)
 
 newRevisionFromConds (array $conditions, int $flags=IDBAccessObject::READ_NORMAL, PageIdentity $page=null, array $options=[])
 Given a set of conditions, fetch a revision. More...
 
 newRevisionSlots ( $revId, $revisionRow, $slotRows, $queryFlags, PageIdentity $page)
 Factory method for RevisionSlots based on a revision ID. More...
 
 storeContentBlob (SlotRecord $slot, PageIdentity $page, array $blobHints=[])
 
 updateSlotsInternal (RevisionRecord $revision, RevisionSlotsUpdate $revisionSlotsUpdate, IDatabase $dbw)
 
 wrapPage (PageIdentity $page)
 

Private Attributes

ActorMigration $actorMigration
 
ActorStore $actorStore
 
SqlBlobStore $blobStore
 
WANObjectCache $cache
 
CommentStore $commentStore
 
IContentHandlerFactory $contentHandlerFactory
 
NameTableStore $contentModelStore
 
HookRunner $hookRunner
 
ILoadBalancer $loadBalancer
 
LoggerInterface $logger
 
PageStore $pageStore
 
SlotRoleRegistry $slotRoleRegistry
 
NameTableStore $slotRoleStore
 
TitleFactory $titleFactory
 
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 the old Revision class (which was later removed in 1.37).

Definition at line 87 of file RevisionStore.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Revision\RevisionStore::__construct ( ILoadBalancer  $loadBalancer,
SqlBlobStore  $blobStore,
WANObjectCache  $cache,
CommentStore  $commentStore,
NameTableStore  $contentModelStore,
NameTableStore  $slotRoleStore,
SlotRoleRegistry  $slotRoleRegistry,
ActorMigration  $actorMigration,
ActorStore  $actorStore,
IContentHandlerFactory  $contentHandlerFactory,
PageStore  $pageStore,
TitleFactory  $titleFactory,
HookContainer  $hookContainer,
  $wikiId = WikiAwareEntity::LOCAL 
)
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
SlotRoleRegistry$slotRoleRegistry
ActorMigration$actorMigration
ActorStore$actorStore
IContentHandlerFactory$contentHandlerFactory
PageStore$pageStore
TitleFactory$titleFactory
HookContainer$hookContainer
false | string$wikiIdRelevant wiki id or WikiAwareEntity::LOCAL for the current one
Todo:
$blobStore should be allowed to be any BlobStore!

Definition at line 189 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\$actorMigration, MediaWiki\Revision\RevisionStore\$actorStore, MediaWiki\Revision\RevisionStore\$blobStore, MediaWiki\Revision\RevisionStore\$cache, MediaWiki\Revision\RevisionStore\$commentStore, MediaWiki\Revision\RevisionStore\$contentHandlerFactory, MediaWiki\Revision\RevisionStore\$contentModelStore, MediaWiki\Revision\RevisionStore\$loadBalancer, MediaWiki\Revision\RevisionStore\$pageStore, MediaWiki\Revision\RevisionStore\$slotRoleRegistry, MediaWiki\Revision\RevisionStore\$slotRoleStore, MediaWiki\Revision\RevisionStore\$titleFactory, and MediaWiki\Revision\RevisionStore\$wikiId.

Member Function Documentation

◆ assertRevisionParameter()

MediaWiki\Revision\RevisionStore::assertRevisionParameter (   $paramName,
  $pageId,
RevisionRecord  $rev = null 
)
private

Asserts that if revision is provided, it's saved and belongs to the page with provided pageId.

Parameters
string$paramName
int$pageId
RevisionRecord | null$rev
Exceptions
InvalidArgumentException

Definition at line 2993 of file RevisionStore.php.

Referenced by MediaWiki\Revision\RevisionStore\countRevisionsBetween(), MediaWiki\Revision\RevisionStore\getAuthorsBetween(), and MediaWiki\Revision\RevisionStore\getRevisionIdsBetween().

◆ checkContent()

MediaWiki\Revision\RevisionStore::checkContent ( Content  $content,
PageIdentity  $page,
string  $role 
)
private

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

Parameters
Content$content
PageIdentity$page
string$role
Exceptions
MWException
MWUnknownContentModelException

Definition at line 983 of file RevisionStore.php.

References $content.

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

◆ checkDatabaseDomain()

◆ constructSlotRecords()

MediaWiki\Revision\RevisionStore::constructSlotRecords (   $revId,
  $slotRows,
  $queryFlags,
PageIdentity  $page,
  $slotContents = null 
)
private

Factory method for SlotRecords based on known slot rows.

Parameters
int$revIdThe revision to load slots for.
\\stdClass[] | IResultWrapper$slotRows
int$queryFlags
PageIdentity$page
array | null$slotContentsa map from blobAddress to slot content blob or Content object.
Returns
SlotRecord[]

Definition at line 1417 of file RevisionStore.php.

References $blob, MediaWiki\Revision\RevisionStore\loadSlotContent(), MediaWiki\Revision\SlotRecord\MAIN, and wfBacktrace().

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

◆ countAuthorsBetween()

MediaWiki\Revision\RevisionStore::countAuthorsBetween (   $pageId,
RevisionRecord  $old = null,
RevisionRecord  $new = null,
Authority  $performer = null,
  $max = null,
  $options = [] 
)

Get the number of authors between the given revisions.

Used for diffs and other things that really need it.

Since
1.35
Parameters
int$pageIdThe id of the page
RevisionRecord | null$oldOld revision . If null is provided, count starting from the first revision (inclusive).
RevisionRecord | null$newNew revision. If null is provided, count until the last revision (inclusive).
Authority | null$performerthe user who's access rights to apply
int | null$maxLimit of Revisions to count, will be incremented to detect truncations.
string | array$optionsSingle option, or an array of options: RevisionStore::INCLUDE_OLD Include $old in the range; $new is excluded. RevisionStore::INCLUDE_NEW Include $new in the range; $old is excluded. RevisionStore::INCLUDE_BOTH Include both $old and $new in the range.
Exceptions
InvalidArgumentExceptionin case either revision is unsaved or the revisions do not belong to the same page or unknown option is passed.
Returns
int Number of revisions authors in the range.

Definition at line 3231 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\getAuthorsBetween().

◆ countRevisionsBetween()

MediaWiki\Revision\RevisionStore::countRevisionsBetween (   $pageId,
RevisionRecord  $old = null,
RevisionRecord  $new = null,
  $max = null,
  $options = [] 
)

Get the number of revisions between the given revisions.

Used for diffs and other things that really need it.

Since
1.35
Parameters
int$pageIdThe id of the page
RevisionRecord | null$oldOld revision. If null is provided, count starting from the first revision (inclusive).
RevisionRecord | null$newNew revision. If null is provided, count until the last revision (inclusive).
int | null$maxLimit of Revisions to count, will be incremented to detect truncations.
string | array$optionsSingle option, or an array of options: RevisionStore::INCLUDE_OLD Include $old in the range; $new is excluded. RevisionStore::INCLUDE_NEW Include $new in the range; $old is excluded. RevisionStore::INCLUDE_BOTH Include both $old and $new in the range.
Exceptions
InvalidArgumentExceptionin case either revision is unsaved or the revisions do not belong to the same page.
Returns
int Number of revisions between these revisions.

Definition at line 3264 of file RevisionStore.php.

References $dbr, MediaWiki\Revision\RevisionStore\assertRevisionParameter(), DB_REPLICA, MediaWiki\Revision\RevisionRecord\DELETED_TEXT, and MediaWiki\Revision\RevisionStore\getDBConnectionRef().

◆ countRevisionsByPageId()

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

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

MCR migration note: this replaced Revision::countByPageId

Parameters
IDatabase$db
int$idPage id
Returns
int

Definition at line 2781 of file RevisionStore.php.

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

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

◆ countRevisionsByTitle()

MediaWiki\Revision\RevisionStore::countRevisionsByTitle ( IDatabase  $db,
PageIdentity  $page 
)

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

MCR migration note: this replaced Revision::countByTitle

Parameters
IDatabase$db
PageIdentity$page
Returns
int

Definition at line 2804 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\countRevisionsByPageId().

◆ ensureRevisionRowMatchesPage()

MediaWiki\Revision\RevisionStore::ensureRevisionRowMatchesPage (   $row,
PageIdentity  $page,
  $context = [] 
)
private

Check that the given row matches the given Title object.

When a mismatch is detected, this tries to re-load the title from primary DB, to avoid spurious errors during page moves.

Parameters
\\stdClass$row
PageIdentity$page
array$context
Returns
Pageidentity

Definition at line 1782 of file RevisionStore.php.

References MediaWiki\$context, Page\PageReference\getDBkey(), Page\PageIdentity\getId(), Page\PageReference\getNamespace(), and wfBacktrace().

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

◆ 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 408 of file RevisionStore.php.

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 391 of file RevisionStore.php.

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

◆ fetchRevisionRowFromConds()

MediaWiki\Revision\RevisionStore::fetchRevisionRowFromConds ( IDatabase  $db,
array  $conditions,
int  $flags = IDBAccessObject::READ_NORMAL,
array  $options = [] 
)
private

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

MCR migration note: this corresponded to Revision::fetchFromConds

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

Definition at line 2335 of file RevisionStore.php.

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

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

◆ findIdenticalRevision()

MediaWiki\Revision\RevisionStore::findIdenticalRevision ( RevisionRecord  $revision,
int  $searchLimit 
)

Tries to find a revision identical to $revision in $searchLimit most recent revisions of this page.

The comparison is based on SHA1s of these revisions.

Since
1.37
Parameters
RevisionRecord$revisionwhich revision to compare to
int$searchLimitHow many recent revisions should be checked
Returns
RevisionRecord|null

Definition at line 3312 of file RevisionStore.php.

References $revQuery, MediaWiki\DAO\WikiAwareEntity\assertWiki(), DB_REPLICA, MediaWiki\Revision\RevisionStore\getDBConnectionRef(), MediaWiki\Revision\RevisionRecord\getPageId(), MediaWiki\Revision\RevisionStore\getQueryInfo(), MediaWiki\Revision\RevisionRecord\getSha1(), and MediaWiki\Revision\RevisionStore\newRevisionFromRow().

◆ getArchiveQueryInfo()

MediaWiki\Revision\RevisionStore::getArchiveQueryInfo ( )

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

Since 1.34, ar_user and ar_user_text have not been present in the database, but they continue to be available in query results as aliases.

MCR migration note: this replaced 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()

Implements MediaWiki\Revision\RevisionFactory.

Definition at line 2549 of file RevisionStore.php.

Referenced by MediaWiki\Revision\RevisionStore\isRevisionRow(), and PageArchive\undeleteRevisions().

◆ getAuthorsBetween()

MediaWiki\Revision\RevisionStore::getAuthorsBetween (   $pageId,
RevisionRecord  $old = null,
RevisionRecord  $new = null,
Authority  $performer = null,
  $max = null,
  $options = [] 
)

Get the authors between the given revisions or revisions.

Used for diffs and other things that really need it.

Since
1.35
Parameters
int$pageIdThe id of the page
RevisionRecord | null$oldOld revision. If null is provided, count starting from the first revision (inclusive).
RevisionRecord | null$newNew revision. If null is provided, count until the last revision (inclusive).
Authority | null$performerthe user who's access rights to apply
int | null$maxLimit of Revisions to count, will be incremented to detect truncations.
string | array$optionsSingle option, or an array of options: RevisionStore::INCLUDE_OLD Include $old in the range; $new is excluded. RevisionStore::INCLUDE_NEW Include $new in the range; $old is excluded. RevisionStore::INCLUDE_BOTH Include both $old and $new in the range.
Exceptions
InvalidArgumentExceptionin case either revision is unsaved or the revisions do not belong to the same page or unknown option is passed.
Returns
UserIdentity[] Names of revision authors in the range

Definition at line 3154 of file RevisionStore.php.

References $dbr, MediaWiki\Revision\RevisionStore\assertRevisionParameter(), DB_REPLICA, MediaWiki\Revision\RevisionRecord\DELETED_USER, MediaWiki\Revision\RevisionRecord\FOR_THIS_USER, and MediaWiki\Revision\RevisionStore\getDBConnectionRef().

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

◆ getBaseRevisionRow()

◆ getContentBlobsForBatch()

MediaWiki\Revision\RevisionStore::getContentBlobsForBatch (   $rowsOrIds,
  $slots = null,
  $queryFlags = 0 
)

Gets raw (serialized) content blobs for the given set of revisions.

Callers are responsible for unserializing and interpreting the content blobs based on the model_name field and the slot role.

This method is intended for bulk operations in maintenance scripts. It may be chosen over newRevisionsFromBatch by code that are only interested in raw content, as opposed to meta data. Code that needs to access meta data of revisions, slots, or content objects should use newRevisionsFromBatch() instead.

Parameters
Traversable | array$rowsOrIdslist of revision ids, or revision rows from a db query.
array | null$slotsthe role names for which to get slots.
int$queryFlags
Returns
StatusValue a status containing, if isOK() returns true, a two-level nested associative array, mapping from revision ID to an associative array that maps from role name to an anonymous object containing two fields:
  • model_name: the name of the content's model
  • blob_data: serialized content data

Definition at line 2201 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\getSlotRowsForBatch().

◆ getDBConnectionRef()

◆ getDBConnectionRefForQueryFlags()

◆ getDBLoadBalancer()

MediaWiki\Revision\RevisionStore::getDBLoadBalancer ( )
private

◆ getFirstRevision()

MediaWiki\Revision\RevisionStore::getFirstRevision (   $page,
int  $flags = IDBAccessObject::READ_NORMAL 
)

Get the first revision of a given page.

Since
1.35
Parameters
LinkTarget | PageIdentity$pageCalling with LinkTarget is deprecated since 1.36
int$flags
Returns
RevisionRecord|null

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 2944 of file RevisionStore.php.

References Title\castFromLinkTarget(), and MediaWiki\Revision\RevisionStore\newRevisionFromConds().

◆ getKnownCurrentRevision()

MediaWiki\Revision\RevisionStore::getKnownCurrentRevision ( PageIdentity  $page,
  $revId = 0 
)

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 replaced Revision::newKnownCurrent

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

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 2872 of file RevisionStore.php.

References $title, Page\PageReference\__toString(), DB_REPLICA, MediaWiki\Revision\RevisionStore\ensureRevisionRowMatchesPage(), MediaWiki\Revision\RevisionStore\fetchRevisionRowFromConds(), Wikimedia\Rdbms\Database\getCacheSetOptions(), MediaWiki\Revision\RevisionStore\getDBConnectionRef(), MediaWiki\Revision\RevisionStore\getRevisionRowCacheKey(), MediaWiki\Revision\RevisionStore\getWikiId(), and MediaWiki\Revision\RevisionStore\newRevisionFromRow().

◆ getNextRevision()

MediaWiki\Revision\RevisionStore::getNextRevision ( RevisionRecord  $rev,
  $flags = self::READ_NORMAL 
)

Get the revision after $rev in the page's history, if any.

Will return null for the latest revision but also for deleted or unsaved revisions.

MCR migration note: this replaced Revision::getNext

Parameters
RevisionRecord$rev
int$flags(optional) $flags include: IDBAccessObject::READ_LATEST: Select the data from the primary DB
Returns
RevisionRecord|null

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 2697 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\getRelativeRevision().

◆ getPage()

MediaWiki\Revision\RevisionStore::getPage ( ?int  $pageId,
?int  $revId,
int  $queryFlags = self::READ_NORMAL 
)
private

Determines the page based on the available information.

Parameters
int | null$pageId
int | null$revId
int$queryFlags
Returns
PageIdentity
Exceptions
RevisionAccessException

Definition at line 308 of file RevisionStore.php.

References $title, DBAccessObjectUtils\hasFlags(), wfBacktrace(), and MediaWiki\Revision\RevisionStore\wrapPage().

Referenced by MediaWiki\Revision\RevisionStore\getTitle(), and MediaWiki\Revision\RevisionStore\newRevisionFromRowAndSlots().

◆ getPreviousRevision()

MediaWiki\Revision\RevisionStore::getPreviousRevision ( RevisionRecord  $rev,
  $flags = self::READ_NORMAL 
)

Get the revision before $rev in the page's history, if any.

Will return null for the first revision but also for deleted or unsaved revisions.

MCR migration note: this replaced Revision::getPrevious

See also
PageArchive::getPreviousRevisionRecord
Parameters
RevisionRecord$rev
int$flags(optional) $flags include: IDBAccessObject::READ_LATEST: Select the data from the primary DB
Returns
RevisionRecord|null

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 2682 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\getRelativeRevision().

◆ 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 corresponded to Revision::getPreviousRevisionId

Parameters
IDatabase$db
RevisionRecord$rev
Returns
int

Definition at line 2712 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\checkDatabaseDomain(), MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\Revision\RevisionRecord\getPageId(), 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 replaced 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
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()

Implements MediaWiki\Revision\RevisionFactory.

Definition at line 2378 of file RevisionStore.php.

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

◆ getRcIdIfUnpatrolled()

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

MCR migration note: this replaced 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 1099 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 replaced Revision::getRecentChange

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

Definition at line 1121 of file RevisionStore.php.

References DBAccessObjectUtils\getDBOptions(), MediaWiki\Revision\RevisionRecord\getId(), and RecentChange\newFromConds().

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

◆ getRelativeRevision()

MediaWiki\Revision\RevisionStore::getRelativeRevision ( RevisionRecord  $rev,
  $flags,
  $dir 
)
private

◆ getRevisionById()

MediaWiki\Revision\RevisionStore::getRevisionById (   $id,
  $flags = 0,
PageIdentity  $page = null 
)

Load a page revision from a given revision ID number.

Returns null if no such revision can be found.

MCR migration note: this replaced Revision::newFromId

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

Parameters
int$id
int$flags(optional)
PageIdentity | null$pageThe page the revision belongs to. Providing the page may improve performance.
Returns
RevisionRecord|null

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 1235 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\newRevisionFromConds().

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

◆ 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 replaced Revision::newFromPageId

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

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

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 1302 of file RevisionStore.php.

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

◆ getRevisionByTimestamp()

MediaWiki\Revision\RevisionStore::getRevisionByTimestamp (   $page,
string  $timestamp,
int  $flags = IDBAccessObject::READ_NORMAL 
)

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 replaced Revision::loadFromTimestamp

Parameters
LinkTarget | PageIdentity$pageCalling with LinkTarget is deprecated since 1.36
string$timestamp
int$flagsBitfield (optional) include: IDBAccessObject::READ_LATEST: Select the data from the primary DB IDBAccessObject::READ_LOCKING: Select & lock the data from the primary DB Default: IDBAccessObject::READ_NORMAL
Returns
RevisionRecord|null

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 1341 of file RevisionStore.php.

References Title\castFromLinkTarget(), MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags(), and MediaWiki\Revision\RevisionStore\newRevisionFromConds().

◆ getRevisionByTitle()

MediaWiki\Revision\RevisionStore::getRevisionByTitle (   $page,
  $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 replaced Revision::newFromTitle

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

Parameters
LinkTarget | PageIdentity$pageCalling with LinkTarget is deprecated since 1.36
int$revId(optional)
int$flagsBitfield (optional)
Returns
RevisionRecord|null

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 1255 of file RevisionStore.php.

References Title\castFromLinkTarget(), MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags(), MediaWiki\Revision\RevisionStore\loadRevisionFromConds(), and MediaWiki\Revision\RevisionStore\newRevisionFromConds().

◆ getRevisionIdsBetween()

MediaWiki\Revision\RevisionStore::getRevisionIdsBetween ( int  $pageId,
RevisionRecord  $old = null,
RevisionRecord  $new = null,
?int  $max = null,
  $options = [],
?string  $order = null,
int  $flags = IDBAccessObject::READ_NORMAL 
)

Get IDs of revisions between the given revisions.

Since
1.36
Parameters
int$pageIdThe id of the page
RevisionRecord | null$oldOld revision. If null is provided, count starting from the first revision (inclusive).
RevisionRecord | null$newNew revision. If null is provided, count until the last revision (inclusive).
int | null$maxLimit of Revisions to count, will be incremented by one to detect truncations.
string | array$optionsSingle option, or an array of options: RevisionStore::INCLUDE_OLD Include $old in the range; $new is excluded. RevisionStore::INCLUDE_NEW Include $new in the range; $old is excluded. RevisionStore::INCLUDE_BOTH Include both $old and $new in the range.
string | null$orderThe direction in which the revisions should be sorted. Possible values:
int$flags
Exceptions
InvalidArgumentExceptionin case either revision is unsaved or the revisions do not belong to the same page or unknown option is passed.
Returns
int[]

Definition at line 3080 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\assertRevisionParameter(), MediaWiki\Revision\RevisionRecord\DELETED_TEXT, and MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags().

◆ getRevisionLimitConditions()

MediaWiki\Revision\RevisionStore::getRevisionLimitConditions ( IDatabase  $dbr,
RevisionRecord  $old = null,
RevisionRecord  $new = null,
  $options = [] 
)
private

Converts revision limits to query conditions.

Parameters
IDatabase$dbr
RevisionRecord | null$oldOld revision. If null is provided, count starting from the first revision (inclusive).
RevisionRecord | null$newNew revision. If null is provided, count until the last revision (inclusive).
string | array$optionsSingle option, or an array of options: RevisionStore::INCLUDE_OLD Include $old in the range; $new is excluded. RevisionStore::INCLUDE_NEW Include $new in the range; $old is excluded. RevisionStore::INCLUDE_BOTH Include both $old and $new in the range.
Returns
array

Definition at line 3020 of file RevisionStore.php.

References $dbr.

◆ 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 2977 of file RevisionStore.php.

References 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 replaced 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 2589 of file RevisionStore.php.

References $dbr, $res, DB_REPLICA, and MediaWiki\Revision\RevisionStore\getDBConnectionRef().

◆ getSlotRowsForBatch()

MediaWiki\Revision\RevisionStore::getSlotRowsForBatch (   $rowsOrIds,
array  $options = [],
  $queryFlags = 0 
)
private

Gets the slot rows associated with a batch of revisions.

The serialized content of each slot can be included by setting the 'blobs' option. Callers are responsible for unserializing and interpreting the content blobs based on the model_name and role_name fields.

Parameters
Traversable | array$rowsOrIdslist of revision ids, or revision or archive rows from a db query.
array$optionsSupports the following options: 'slots' - a list of slot role names to fetch. If omitted or true or null, all slots are fetched 'blobs' - whether the serialized content of each slot should be loaded. If true, the serialiezd content will be present in the slot row in the blob_data field.
int$queryFlags
Returns
StatusValue a status containing, if isOK() returns true, a two-level nested associative array, mapping from revision ID to an associative array that maps from role name to a database row object. The database row object will contain the fields defined by getSlotQueryInfo() with the 'content' flag set, plus the blob_data field if the 'blobs' is set in $options. The model_name and role_name fields will also be set.

Definition at line 2085 of file RevisionStore.php.

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

Referenced by MediaWiki\Revision\RevisionStore\getContentBlobsForBatch(), and MediaWiki\Revision\RevisionStore\newRevisionsFromBatch().

◆ 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()
  • keys: (associative array) to look up fields to match against. In particular, the field that can be used to find slots by rev_id can be found in ['keys']['rev_id'].

Definition at line 2458 of file RevisionStore.php.

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

◆ getTimestampFromId()

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

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

Historically, there was an extra Title parameter that was passed before $id. This is no longer needed and is deprecated in 1.34.

MCR migration note: this replaced Revision::getTimestampFromId

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

Implements MediaWiki\Revision\RevisionLookup.

Definition at line 2748 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags().

Referenced by MediaWiki\Revision\RevisionStore\getRelativeRevision(), and PageArchive\undeleteRevisions().

◆ getTitle()

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

Determines the page Title based on the available information.

MCR migration note: this corresponded to Revision::getTitle

Deprecated:
since 1.36, Use RevisionRecord::getPage() instead.
Note
The resulting Title object will be misleading if the RevisionStore is not for the local wiki.
Parameters
int | null$pageId
int | null$revId
int$queryFlags
Returns
Title
Exceptions
RevisionAccessException

Definition at line 288 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\getPage(), and wfDeprecatedMsg().

◆ getWikiId()

MediaWiki\Revision\RevisionStore::getWikiId ( )

Get the ID of the wiki this revision belongs to.

Returns
string|false The wiki's logical name, of false to indicate the local wiki.

Definition at line 247 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\$wikiId.

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

◆ insertContentRowOn()

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

◆ insertIpChangesRow()

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

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

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

Definition at line 738 of file RevisionStore.php.

References MediaWiki\User\UserIdentity\getId(), MediaWiki\User\UserIdentity\getName(), MediaWiki\Revision\RevisionRecord\getTimestamp(), 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 231 of file RevisionStore.php.

◆ isRevisionRow()

MediaWiki\Revision\RevisionStore::isRevisionRow (   $row,
string  $table = '' 
)

Determine whether the parameter is a row containing all the fields that RevisionStore needs to create a RevisionRecord from the row.

Parameters
mixed$row
string$table'archive' or empty
Returns
bool

Implements MediaWiki\Revision\RevisionFactory.

Definition at line 2518 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\getArchiveQueryInfo(), and MediaWiki\Revision\RevisionStore\getQueryInfo().

◆ loadRevisionFromConds()

MediaWiki\Revision\RevisionStore::loadRevisionFromConds ( IDatabase  $db,
array  $conditions,
int  $flags = IDBAccessObject::READ_NORMAL,
PageIdentity  $page = null,
array  $options = [] 
)
private

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

MCR migration note: this corresponded to Revision::loadFromConds

Parameters
IDatabase$db
array$conditions
int$flags(optional)
PageIdentity | null$page(optional) additional query options
array$options(optional) additional query options
Returns
RevisionRecord|null

Definition at line 2290 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\fetchRevisionRowFromConds(), and MediaWiki\Revision\RevisionStore\newRevisionFromRow().

Referenced by MediaWiki\Revision\RevisionStore\getRevisionByPageId(), MediaWiki\Revision\RevisionStore\getRevisionByTitle(), MediaWiki\Revision\RevisionStore\newNullRevision(), and MediaWiki\Revision\RevisionStore\newRevisionFromConds().

◆ loadSlotContent()

MediaWiki\Revision\RevisionStore::loadSlotContent ( SlotRecord  $slot,
?string  $blobData = null,
?string  $blobFlags = null,
?string  $blobFormat = null,
int  $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 corresponded 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 1153 of file RevisionStore.php.

References MediaWiki\Revision\SlotRecord\getAddress(), MediaWiki\Revision\SlotRecord\getModel(), MediaWiki\Revision\SlotRecord\getRevision(), MediaWiki\Revision\SlotRecord\getRole(), MediaWiki\Revision\SlotRecord\hasAddress(), and wfBacktrace().

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

◆ loadSlotRecords()

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

◆ newNullRevision()

MediaWiki\Revision\RevisionStore::newNullRevision ( IDatabase  $dbw,
PageIdentity  $page,
CommentStoreComment  $comment,
  $minor,
UserIdentity  $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 replaced 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
PageIdentity$pagethe page to read from
CommentStoreComment$commentRevisionRecord's summary
bool$minorWhether the revision should be considered as minor
UserIdentity$userThe user to attribute the revision to
Returns
RevisionRecord|null RevisionRecord or null on error

Definition at line 1028 of file RevisionStore.php.

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

◆ newRevisionFromArchiveRow()

MediaWiki\Revision\RevisionStore::newRevisionFromArchiveRow (   $row,
  $queryFlags = 0,
PageIdentity  $page = null,
array  $overrides = [] 
)

Make a fake RevisionRecord object from an archive table row.

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

The user ID and user name may optionally be supplied using the aliases ar_user and ar_user_text (the names of fields which existed before MW 1.34).

MCR migration note: this replaced Revision::newFromArchiveRow

Parameters
\\stdClass$row
int$queryFlags
PageIdentity | null$page
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 1539 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\newRevisionFromArchiveRowAndSlots().

Referenced by PageArchive\undeleteRevisions().

◆ newRevisionFromArchiveRowAndSlots()

MediaWiki\Revision\RevisionStore::newRevisionFromArchiveRowAndSlots ( stdClass  $row,
  $slots,
int  $queryFlags = 0,
?PageIdentity  $page = null,
array  $overrides = [] 
)
See also
newRevisionFromArchiveRow()
Since
1.35
Parameters
stdClass$row
null | stdClass[] | RevisionSlots$slots
  • Database rows generated from a query based on getSlotsQueryInfo with the 'content' flag set. Or
  • RevisionSlots instance
int$queryFlags
PageIdentity | null$page
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

Definition at line 1588 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags(), Title\makeTitle(), and MediaWiki\Revision\RevisionStore\newRevisionSlots().

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

◆ newRevisionFromConds()

MediaWiki\Revision\RevisionStore::newRevisionFromConds ( array  $conditions,
int  $flags = IDBAccessObject::READ_NORMAL,
PageIdentity  $page = null,
array  $options = [] 
)
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 primary database.

MCR migration note: this corresponded to Revision::newFromConds

Parameters
array$conditions
int$flags(optional)
PageIdentity | null$page(optional)
array$options(optional) additional query options
Returns
RevisionRecord|null

Definition at line 2250 of file RevisionStore.php.

References DB_PRIMARY, MediaWiki\Revision\RevisionStore\getDBConnectionRef(), MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags(), MediaWiki\Revision\RevisionStore\getDBLoadBalancer(), and MediaWiki\Revision\RevisionStore\loadRevisionFromConds().

Referenced by MediaWiki\Revision\RevisionStore\getFirstRevision(), 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,
PageIdentity  $page = null,
  $fromCache = false 
)
See also
RevisionFactory::newRevisionFromRow

MCR migration note: this replaced Revision::newFromRow

Parameters
\\stdClass$rowA database row generated from a query based on getQueryInfo()
int$queryFlags
PageIdentity | null$pagePreloaded page object
bool$fromCacheif true, the returned RevisionRecord will ensure that no stale data is returned from getters, by querying the database as needed
Returns
RevisionRecord

Definition at line 1560 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\newRevisionFromRowAndSlots().

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

◆ newRevisionFromRowAndSlots()

MediaWiki\Revision\RevisionStore::newRevisionFromRowAndSlots ( stdClass  $row,
  $slots,
int  $queryFlags = 0,
?PageIdentity  $page = null,
bool  $fromCache = false 
)
See also
newFromRevisionRow()
Parameters
stdClass$rowA database row generated from a query based on getQueryInfo()
null | stdClass[] | RevisionSlots$slots
  • Database rows generated from a query based on getSlotsQueryInfo with the 'content' flag set. Or
  • RevisionSlots instance
int$queryFlags
PageIdentity | null$page
bool$fromCacheif true, the returned RevisionRecord will ensure that no stale data is returned from getters, by querying the database as needed
Returns
RevisionRecord
Exceptions
MWException
RevisionAccessException
See also
RevisionFactory::newRevisionFromRow

Definition at line 1663 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\$wikiId, MediaWiki\Revision\RevisionStore\ensureRevisionRowMatchesPage(), MediaWiki\Revision\RevisionStore\fetchRevisionRowFromConds(), MediaWiki\Revision\RevisionStore\getDBConnectionRefForQueryFlags(), MediaWiki\Revision\RevisionStore\getPage(), MediaWiki\Revision\RevisionStore\newRevisionSlots(), wfBacktrace(), and MediaWiki\Revision\RevisionStore\wrapPage().

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

◆ newRevisionsFromBatch()

MediaWiki\Revision\RevisionStore::newRevisionsFromBatch (   $rows,
array  $options = [],
  $queryFlags = 0,
PageIdentity  $page = null 
)

Construct a RevisionRecord instance for each row in $rows, and return them as an associative array indexed by revision ID.

Use getQueryInfo() or getArchiveQueryInfo() to construct the query that produces the rows.

Parameters
IResultWrapper | \\stdClass[]$rowsthe rows to construct revision records from
array$optionsSupports the following options: 'slots' - whether metadata about revision slots should be loaded immediately. Supports falsy or truthy value as well as an explicit list of slot role names. The main slot will always be loaded. 'content' - whether the actual content of the slots should be preloaded. 'archive' - whether the rows where generated using getArchiveQueryInfo(), rather than getQueryInfo.
int$queryFlags
PageIdentity | null$pageThe page to which all the revision rows belong, if there is such a page and the caller has it handy, so we don't have to look it up again. If this parameter is given and any of the rows has a rev_page_id that is different from Article Id associated with the page, an InvalidArgumentException is thrown.
Returns
StatusValue a status with a RevisionRecord[] of successfully fetched revisions and an array of errors for the revisions failed to fetch.

Definition at line 1874 of file RevisionStore.php.

References $t, MediaWiki\Revision\RevisionStore\getSlotRowsForBatch(), if, MediaWiki\Revision\SlotRecord\MAIN, Title\makeTitle(), Title\newFromIDs(), and Title\newFromRow().

◆ newRevisionSlots()

MediaWiki\Revision\RevisionStore::newRevisionSlots (   $revId,
  $revisionRow,
  $slotRows,
  $queryFlags,
PageIdentity  $page 
)
private

Factory method for RevisionSlots based on a revision ID.

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
\\stdClass$revisionRow
\\stdClass[] | null$slotRows
int$queryFlags
PageIdentity$page
Returns
RevisionSlots
Exceptions
MWException

Definition at line 1495 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\constructSlotRecords(), and MediaWiki\Revision\RevisionStore\loadSlotRecords().

Referenced by MediaWiki\Revision\RevisionStore\newRevisionFromArchiveRowAndSlots(), and MediaWiki\Revision\RevisionStore\newRevisionFromRowAndSlots().

◆ setLogger()

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

Definition at line 224 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\$logger.

◆ storeContentBlob()

MediaWiki\Revision\RevisionStore::storeContentBlob ( SlotRecord  $slot,
PageIdentity  $page,
array  $blobHints = [] 
)
private

◆ updateSlotsInternal()

◆ updateSlotsOn()

MediaWiki\Revision\RevisionStore::updateSlotsOn ( RevisionRecord  $revision,
RevisionSlotsUpdate  $revisionSlotsUpdate,
IDatabase  $dbw 
)

Update derived slots in an existing revision into the database, returning the modified slots on success.

Parameters
RevisionRecord$revisionAfter this method returns, the $revision object will be obsolete in that it does not have the new slots.
RevisionSlotsUpdate$revisionSlotsUpdate
IDatabase$dbw(primary connection)
Returns
SlotRecord[] the new slot records.
Access: internal

Definition at line 544 of file RevisionStore.php.

References MediaWiki\Revision\RevisionStore\checkDatabaseDomain(), Wikimedia\Rdbms\IDatabase\doAtomicSection(), MediaWiki\Storage\RevisionSlotsUpdate\getModifiedRoles(), MediaWiki\Storage\RevisionSlotsUpdate\getRemovedRoles(), and MediaWiki\Revision\RevisionStore\updateSlotsInternal().

◆ 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 replaced 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 had been deprecated since 1.24 (the Revision class was removed entirely in 1.37).
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 2830 of file RevisionStore.php.

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

◆ wrapPage()

MediaWiki\Revision\RevisionStore::wrapPage ( PageIdentity  $page)
private
Parameters
PageIdentity$page
Returns
PageIdentity

Definition at line 370 of file RevisionStore.php.

Referenced by MediaWiki\Revision\RevisionStore\getPage(), and MediaWiki\Revision\RevisionStore\newRevisionFromRowAndSlots().

Member Data Documentation

◆ $actorMigration

ActorMigration MediaWiki\Revision\RevisionStore::$actorMigration
private

Definition at line 130 of file RevisionStore.php.

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

◆ $actorStore

ActorStore MediaWiki\Revision\RevisionStore::$actorStore
private

Definition at line 133 of file RevisionStore.php.

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

◆ $blobStore

SqlBlobStore MediaWiki\Revision\RevisionStore::$blobStore
private

Definition at line 105 of file RevisionStore.php.

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

◆ $cache

WANObjectCache MediaWiki\Revision\RevisionStore::$cache
private

Definition at line 120 of file RevisionStore.php.

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

◆ $commentStore

CommentStore MediaWiki\Revision\RevisionStore::$commentStore
private

Definition at line 125 of file RevisionStore.php.

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

◆ $contentHandlerFactory

IContentHandlerFactory MediaWiki\Revision\RevisionStore::$contentHandlerFactory
private

Definition at line 154 of file RevisionStore.php.

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

◆ $contentModelStore

NameTableStore MediaWiki\Revision\RevisionStore::$contentModelStore
private

Definition at line 143 of file RevisionStore.php.

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

◆ $hookRunner

HookRunner MediaWiki\Revision\RevisionStore::$hookRunner
private

Definition at line 157 of file RevisionStore.php.

◆ $loadBalancer

ILoadBalancer MediaWiki\Revision\RevisionStore::$loadBalancer
private

◆ $logger

LoggerInterface MediaWiki\Revision\RevisionStore::$logger
private

Definition at line 138 of file RevisionStore.php.

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

◆ $pageStore

PageStore MediaWiki\Revision\RevisionStore::$pageStore
private

Definition at line 160 of file RevisionStore.php.

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

◆ $slotRoleRegistry

SlotRoleRegistry MediaWiki\Revision\RevisionStore::$slotRoleRegistry
private

Definition at line 151 of file RevisionStore.php.

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

◆ $slotRoleStore

NameTableStore MediaWiki\Revision\RevisionStore::$slotRoleStore
private

Definition at line 148 of file RevisionStore.php.

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

◆ $titleFactory

TitleFactory MediaWiki\Revision\RevisionStore::$titleFactory
private

Definition at line 163 of file RevisionStore.php.

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

◆ $wikiId

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

◆ INCLUDE_BOTH

const MediaWiki\Revision\RevisionStore::INCLUDE_BOTH = 'include_both'

Definition at line 100 of file RevisionStore.php.

Referenced by MediaWiki\Storage\RevertedTagUpdate\doUpdate().

◆ INCLUDE_NEW

const MediaWiki\Revision\RevisionStore::INCLUDE_NEW = 'include_new'

Definition at line 99 of file RevisionStore.php.

◆ INCLUDE_OLD

const MediaWiki\Revision\RevisionStore::INCLUDE_OLD = 'include_old'

Definition at line 98 of file RevisionStore.php.

◆ ORDER_NEWEST_TO_OLDEST

const MediaWiki\Revision\RevisionStore::ORDER_NEWEST_TO_OLDEST = 'DESC'

Definition at line 95 of file RevisionStore.php.

◆ ORDER_OLDEST_TO_NEWEST

const MediaWiki\Revision\RevisionStore::ORDER_OLDEST_TO_NEWEST = 'ASC'

Definition at line 94 of file RevisionStore.php.

◆ ROW_CACHE_KEY

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

Definition at line 92 of file RevisionStore.php.


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