BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
MediaWiki\Storage\RevisionStore Class Reference
Inheritance diagram for MediaWiki\Storage\RevisionStore:
Collaboration diagram for MediaWiki\Storage\RevisionStore:

Public Member Functions

 __construct (LoadBalancer $loadBalancer, SqlBlobStore $blobStore, WANObjectCache $cache, CommentStore $commentStore, ActorMigration $actorMigration, $wikiId=false)
 
 setLogger (LoggerInterface $logger)
 
 isReadOnly ()
 
 getContentHandlerUseDB ()
 
 setContentHandlerUseDB ($contentHandlerUseDB)
 
 getTitle ($pageId, $revId, $queryFlags=self::READ_NORMAL)
 
 insertRevisionOn (RevisionRecord $rev, IDatabase $dbw)
 
 newNullRevision (IDatabase $dbw, Title $title, CommentStoreComment $comment, $minor, User $user)
 
 getRcIdIfUnpatrolled (RevisionRecord $rev)
 
 getRecentChange (RevisionRecord $rev, $flags=0)
 
 getRevisionById ($id, $flags=0)
 
 getRevisionByTitle (LinkTarget $linkTarget, $revId=0, $flags=0)
 
 getRevisionByPageId ($pageId, $revId=0, $flags=0)
 
 getRevisionByTimestamp ($title, $timestamp)
 
 newRevisionFromArchiveRow ($row, $queryFlags=0, Title $title=null, array $overrides=[])
 
 newRevisionFromRow ($row, $queryFlags=0, Title $title=null)
 
 newMutableRevisionFromArray (array $fields, $queryFlags=0, Title $title=null)
 
 loadRevisionFromId (IDatabase $db, $id)
 
 loadRevisionFromPageId (IDatabase $db, $pageid, $id=0)
 
 loadRevisionFromTitle (IDatabase $db, $title, $id=0)
 
 loadRevisionFromTimestamp (IDatabase $db, $title, $timestamp)
 
 getQueryInfo ($options=[])
 
 getArchiveQueryInfo ()
 
 getRevisionSizes (array $revIds)
 
 listRevisionSizes (IDatabase $db, array $revIds)
 
 getPreviousRevision (RevisionRecord $rev, Title $title=null)
 
 getNextRevision (RevisionRecord $rev, Title $title=null)
 
 getTimestampFromId ($title, $id, $flags=0)
 
 countRevisionsByPageId (IDatabase $db, $id)
 
 countRevisionsByTitle (IDatabase $db, $title)
 
 userWasLastToEdit (IDatabase $db, $pageId, $userId, $since)
 
 getKnownCurrentRevision (Title $title, $revId)
 

Additional Inherited Members

- Public Attributes inherited from IDBAccessObject
const READ_NORMAL = 0
 
const READ_LATEST = 1
 
const READ_LOCKING = 3
 
const READ_EXCLUSIVE = 7
 
const READ_LATEST_IMMUTABLE = 8
 
const READ_NONE = -1
 

Detailed Description

Service for looking up page revisions.

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

Constructor & Destructor Documentation

MediaWiki\Storage\RevisionStore::__construct ( LoadBalancer  $loadBalancer,
SqlBlobStore  $blobStore,
WANObjectCache  $cache,
CommentStore  $commentStore,
ActorMigration  $actorMigration,
  $wikiId = false 
)
Todo:
$blobStore should be allowed to be any BlobStore!
Parameters
LoadBalancer$loadBalancer
SqlBlobStore$blobStore
WANObjectCache$cache
CommentStore$commentStore
ActorMigration$actorMigration
bool | string$wikiId

Member Function Documentation

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

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

MCR migration note: this replaces Revision::countByPageId

Parameters
IDatabase$db
int$idPage id
Returns
int
MediaWiki\Storage\RevisionStore::countRevisionsByTitle ( IDatabase  $db,
  $title 
)

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

MCR migration note: this replaces Revision::countByTitle

Parameters
IDatabase$db
Title$title
Returns
int
MediaWiki\Storage\RevisionStore::getArchiveQueryInfo ( )

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

MCR migration note: this replaces Revision::getArchiveQueryInfo

Since
1.31
Returns
array With three keys:
  • tables: (string[]) to include in the $table to IDatabase->select()
  • fields: (string[]) to include in the $vars to IDatabase->select()
  • joins: (array) to include in the $join_conds to IDatabase->select()
MediaWiki\Storage\RevisionStore::getContentHandlerUseDB ( )
Returns
bool
MediaWiki\Storage\RevisionStore::getKnownCurrentRevision ( Title  $title,
  $revId 
)

Load a revision based on a known page ID and current revision ID from the DB

This method allows for the use of caching, though accessing anything that normally requires permission checks (aside from the text) will trigger a small DB lookup.

MCR migration note: this replaces Revision::newKnownCurrent

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

Implements MediaWiki\Storage\RevisionLookup.

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

Get next revision for this title

MCR migration note: this replaces Revision::getNext

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

Implements MediaWiki\Storage\RevisionLookup.

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

Get previous revision for this title

MCR migration note: this replaces Revision::getPrevious

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

Implements MediaWiki\Storage\RevisionLookup.

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

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

MCR migration note: this replaces Revision::getQueryInfo

Since
1.31
Parameters
array$optionsAny combination of the following strings
  • 'page': Join with the page table, and select fields to identify the page
  • 'user': Join with the user table, and select the user name
  • 'text': Join with the text table, and select fields to load page text
Returns
array With three keys:
  • tables: (string[]) to include in the $table to IDatabase->select()
  • fields: (string[]) to include in the $vars to IDatabase->select()
  • joins: (array) to include in the $join_conds to IDatabase->select()
MediaWiki\Storage\RevisionStore::getRcIdIfUnpatrolled ( RevisionRecord  $rev)

MCR migration note: this replaces Revision::isUnpatrolled

Todo:
This is overly specific, so move or kill this method.
Parameters
RevisionRecord$rev
Returns
int Rcid of the unpatrolled row, zero if there isn't one
MediaWiki\Storage\RevisionStore::getRecentChange ( RevisionRecord  $rev,
  $flags = 0 
)

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

MCR migration note: this replaces Revision::getRecentChange

Todo:
move this somewhere else?
Parameters
RevisionRecord$rev
int$flags(optional) $flags include: IDBAccessObject::READ_LATEST: Select the data from the master
Returns
null|RecentChange
MediaWiki\Storage\RevisionStore::getRevisionById (   $id,
  $flags = 0 
)

Load a page revision from a given revision ID number. Returns null if no such revision can be found.

MCR migration note: this replaces Revision::newFromId

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

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

Implements MediaWiki\Storage\RevisionLookup.

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

Load either the current, or a specified, revision that's attached to a given page ID. Returns null if no such revision can be found.

MCR migration note: this replaces Revision::newFromPageId

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

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

Implements MediaWiki\Storage\RevisionLookup.

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

Load the revision for the given title with the given timestamp. WARNING: Timestamps may in some circumstances not be unique, so this isn't the best key to use.

MCR migration note: this replaces Revision::loadFromTimestamp

Parameters
Title$title
string$timestamp
Returns
RevisionRecord|null
MediaWiki\Storage\RevisionStore::getRevisionByTitle ( LinkTarget  $linkTarget,
  $revId = 0,
  $flags = 0 
)

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

MCR migration note: this replaces Revision::newFromTitle

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

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

Implements MediaWiki\Storage\RevisionLookup.

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

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

MCR migration note: this replaces Revision::getParentLengths

Parameters
int[]$revIds
Returns
int[] associative array mapping revision IDs from $revIds to the nominal size of the corresponding revision.
MediaWiki\Storage\RevisionStore::getTimestampFromId (   $title,
  $id,
  $flags = 0 
)

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

MCR migration note: this replaces Revision::getTimestampFromId

Parameters
Title$title
int$id
int$flags
Returns
string|bool False if not found
MediaWiki\Storage\RevisionStore::getTitle (   $pageId,
  $revId,
  $queryFlags = self::READ_NORMAL 
)

Determines the page Title based on the available information.

MCR migration note: this corresponds to Revision::getTitle

Note
this method should be private, external use should be avoided!
Parameters
int | null$pageId
int | null$revId
int$queryFlags
Returns
Title
Exceptions
RevisionAccessException
MediaWiki\Storage\RevisionStore::insertRevisionOn ( RevisionRecord  $rev,
IDatabase  $dbw 
)

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

MCR migration note: this replaces Revision::insertOn

Parameters
RevisionRecord$rev
IDatabase$dbw(master connection)
Exceptions
InvalidArgumentException
Returns
RevisionRecord the new revision record.
MediaWiki\Storage\RevisionStore::isReadOnly ( )
Returns
bool Whether the store is read-only
MediaWiki\Storage\RevisionStore::listRevisionSizes ( IDatabase  $db,
array  $revIds 
)

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

MCR migration note: this replaces Revision::getParentLengths

Deprecated:
use RevisionStore::getRevisionSizes instead.
Parameters
IDatabase$db
int[]$revIds
Returns
int[] associative array mapping revision IDs from $revIds to the nominal size of the corresponding revision.
MediaWiki\Storage\RevisionStore::loadRevisionFromId ( IDatabase  $db,
  $id 
)

Load a page revision from a given revision ID number. Returns null if no such revision can be found.

MCR migration note: this corresponds to Revision::loadFromId

Note
direct use is deprecated!
Todo:
remove when unused! there seem to be no callers of Revision::loadFromId
Parameters
IDatabase$db
int$id
Returns
RevisionRecord|null
MediaWiki\Storage\RevisionStore::loadRevisionFromPageId ( IDatabase  $db,
  $pageid,
  $id = 0 
)

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

MCR migration note: this replaces Revision::loadFromPageId

Note
direct use is deprecated!
Todo:
remove when unused!
Parameters
IDatabase$db
int$pageid
int$id
Returns
RevisionRecord|null
MediaWiki\Storage\RevisionStore::loadRevisionFromTimestamp ( IDatabase  $db,
  $title,
  $timestamp 
)

Load the revision for the given title with the given timestamp. WARNING: Timestamps may in some circumstances not be unique, so this isn't the best key to use.

MCR migration note: this replaces Revision::loadFromTimestamp

Note
direct use is deprecated! Use getRevisionFromTimestamp instead!
Todo:
remove when unused!
Parameters
IDatabase$db
Title$title
string$timestamp
Returns
RevisionRecord|null
MediaWiki\Storage\RevisionStore::loadRevisionFromTitle ( IDatabase  $db,
  $title,
  $id = 0 
)

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

MCR migration note: this replaces Revision::loadFromTitle

Note
direct use is deprecated!
Todo:
remove when unused!
Parameters
IDatabase$db
Title$title
int$id
Returns
RevisionRecord|null
MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray ( array  $fields,
  $queryFlags = 0,
Title  $title = null 
)

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

MCR migration note: this replaces Revision::newFromRow

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

Implements MediaWiki\Storage\RevisionFactory.

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

Create a new null-revision for insertion into a page's history. This will not re-save the text, but simply refer to the text from the previous version.

Such revisions can for instance identify page rename operations and other such meta-modifications.

MCR migration note: this replaces Revision::newNullRevision

Todo:
Introduce newFromParentRevision(). newNullRevision can then be based on that (or go away).
Parameters
IDatabase$dbw
Title$titleTitle of the page to read from
CommentStoreComment$commentRevisionRecord's summary
bool$minorWhether the revision should be considered as minor
User$userThe user to attribute the revision to
Returns
RevisionRecord|null RevisionRecord or null on error
MediaWiki\Storage\RevisionStore::newRevisionFromArchiveRow (   $row,
  $queryFlags = 0,
Title  $title = null,
array  $overrides = [] 
)

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

MCR migration note: this replaces Revision::newFromArchiveRow

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

Implements MediaWiki\Storage\RevisionFactory.

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

MCR migration note: this replaces Revision::newFromRow

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

Implements MediaWiki\Storage\RevisionFactory.

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

Sets a logger instance on the object.

Parameters
LoggerInterface$logger
Returns
void

Implements Psr\Log\LoggerAwareInterface.

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

Check if no edits were made by other users since the time a user started editing the page. Limit to 50 revisions for the sake of performance.

MCR migration note: this replaces Revision::userWasLastToEdit

Deprecated:
since 1.31; Can possibly be removed, since the self-conflict suppression logic in EditPage that uses this seems conceptually dubious. Revision::userWasLastToEdit has been deprecated since 1.24.
Parameters
IDatabase$dbThe Database to perform the check on.
int$pageIdThe ID of the page in question
int$userIdThe ID of the user in question
string$sinceLook at edits since this time
Returns
bool True if the given user was the only one to edit since the given timestamp

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