MediaWiki  REL1_31
MediaWiki\Storage\RevisionRecord Class Reference

Page revision base class. More...

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

Public Member Functions

 __construct (Title $title, RevisionSlots $slots, $wikiId=false)
 
 __sleep ()
 Implemented to defy serialization. More...
 
 getComment ( $audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision comment, if it's available to the specified audience. More...
 
 getContent ( $role, $audience=self::FOR_PUBLIC, User $user=null)
 Returns the Content of the given slot of this revision. More...
 
 getId ()
 Get revision ID. More...
 
 getPageAsLinkTarget ()
 Returns the title of the page this revision is associated with as a LinkTarget object. More...
 
 getPageId ()
 Get the page ID. More...
 
 getParentId ()
 Get parent revision ID (the original previous page revision). More...
 
 getSha1 ()
 Returns the base36 sha1 of this revision. More...
 
 getSize ()
 Returns the nominal size of this revision, in bogo-bytes. More...
 
 getSlot ( $role, $audience=self::FOR_PUBLIC, User $user=null)
 Returns meta-data for the given slot. More...
 
 getSlotRoles ()
 Returns the slot names (roles) of all slots present in this revision. More...
 
 getTimestamp ()
 MCR migration note: this replaces Revision::getTimestamp. More...
 
 getUser ( $audience=self::FOR_PUBLIC, User $user=null)
 Fetch revision's author's user identity, if it's available to the specified audience. More...
 
 getVisibility ()
 Get the deletion bitfield of the revision. More...
 
 getWikiId ()
 Get the ID of the wiki this revision belongs to. More...
 
 hasSameContent (RevisionRecord $rec)
 
 hasSlot ( $role)
 Returns whether the given slot is defined in this revision. More...
 
 isDeleted ( $field)
 MCR migration note: this replaces Revision::isDeleted. More...
 
 isMinor ()
 MCR migration note: this replaces Revision::isMinor. More...
 

Static Public Member Functions

static userCanBitfield ( $bitfield, $field, User $user, Title $title=null)
 Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted. More...
 

Public Attributes

const DELETED_COMMENT = 2
 
const DELETED_RESTRICTED = 8
 
const DELETED_TEXT = 1
 
const DELETED_USER = 4
 
const FOR_PUBLIC = 1
 
const FOR_THIS_USER = 2
 
const RAW = 3
 
const SUPPRESSED_ALL = 15
 
const SUPPRESSED_USER = 12
 

Protected Member Functions

 audienceCan ( $field, $audience, User $user=null)
 Check that the given audience has access to the given field. More...
 
 userCan ( $field, User $user)
 Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted. More...
 

Protected Attributes

CommentStoreComment null $mComment
 
int $mDeleted = 0
 using the DELETED_XXX and SUPPRESSED_XXX flags More...
 
int null $mId
 
bool $mMinorEdit = false
 
int null $mPageId
 
int null $mParentId
 
string null $mSha1
 
int null $mSize
 
RevisionSlots $mSlots
 
string null $mTimestamp
 
Title $mTitle
 
UserIdentity null $mUser
 
string $mWiki = false
 Wiki ID; false means the current wiki. More...
 

Detailed Description

Page revision base class.

RevisionRecords are considered value objects, but they may use callbacks for lazy loading. Note that while the base class has no setters, subclasses may offer a mutable interface.

Since
1.31

Definition at line 44 of file RevisionRecord.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\RevisionRecord::__construct ( Title  $title,
RevisionSlots  $slots,
  $wikiId = false 
)
Note
Avoid calling this constructor directly. Use the appropriate methods in RevisionStore instead.
Parameters
Title$titleThe title of the page this Revision is associated with.
RevisionSlots$slotsThe slots of this revision.
bool | string$wikiIdthe wiki ID of the site this Revision belongs to, or false for the local site.
Exceptions
MWException

Definition at line 99 of file RevisionRecord.php.

References $title.

Member Function Documentation

◆ __sleep()

MediaWiki\Storage\RevisionRecord::__sleep ( )

Implemented to defy serialization.

Exceptions
LogicExceptionalways

Definition at line 115 of file RevisionRecord.php.

◆ audienceCan()

MediaWiki\Storage\RevisionRecord::audienceCan (   $field,
  $audience,
User  $user = null 
)
protected

Check that the given audience has access to the given field.

MCR migration note: this corresponds to Revision::userCan

Parameters
int$fieldOne of self::DELETED_TEXT, self::DELETED_COMMENT, self::DELETED_USER
int$audienceOne of: RevisionRecord::FOR_PUBLIC to be displayed to all users RevisionRecord::FOR_THIS_USER to be displayed to the given user RevisionRecord::RAW get the text regardless of permissions
User | null$userUser object to check. Required if $audience is FOR_THIS_USER, ignored otherwise.
Returns
bool

Definition at line 413 of file RevisionRecord.php.

References $user, MediaWiki\Storage\RevisionRecord\isDeleted(), and MediaWiki\Storage\RevisionRecord\userCan().

Referenced by MediaWiki\Storage\RevisionRecord\getComment(), MediaWiki\Storage\RevisionRecord\getContent(), MediaWiki\Storage\RevisionRecord\getSlot(), and MediaWiki\Storage\RevisionRecord\getUser().

◆ getComment()

MediaWiki\Storage\RevisionRecord::getComment (   $audience = self::FOR_PUBLIC,
User  $user = null 
)

Fetch revision comment, if it's available to the specified audience.

If the specified audience does not have access to the comment, this will return null. Depending on the concrete subclass, null may also be returned if the comment is not yet specified.

MCR migration note: this replaces Revision::getComment

Parameters
int$audienceOne of: RevisionRecord::FOR_PUBLIC to be displayed to all users RevisionRecord::FOR_THIS_USER to be displayed to the given user RevisionRecord::RAW get the text regardless of permissions
User | null$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
CommentStoreComment|null

Reimplemented in MediaWiki\Storage\RevisionStoreRecord, and MediaWiki\Storage\RevisionArchiveRecord.

Definition at line 346 of file RevisionRecord.php.

References MediaWiki\Storage\RevisionRecord\$mComment, $user, and MediaWiki\Storage\RevisionRecord\audienceCan().

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual(), and MediaWiki\Storage\RevisionStore\insertRevisionOn().

◆ getContent()

MediaWiki\Storage\RevisionRecord::getContent (   $role,
  $audience = self::FOR_PUBLIC,
User  $user = null 
)

Returns the Content of the given slot of this revision.

Call getSlotNames() to get a list of available slots.

Note that for mutable Content objects, each call to this method will return a fresh clone.

MCR migration note: this replaces Revision::getContent

Parameters
string$roleThe role name of the desired slot
int$audience
User | null$user
Exceptions
RevisionAccessExceptionif the slot does not exist or slot data could not be lazy-loaded.
Returns
Content|null The content of the given slot, or null if access is forbidden.

Definition at line 165 of file RevisionRecord.php.

References $user, MediaWiki\Storage\RevisionRecord\audienceCan(), and MediaWiki\Storage\RevisionRecord\getSlot().

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), and MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual().

◆ getId()

MediaWiki\Storage\RevisionRecord::getId ( )

Get revision ID.

Depending on the concrete subclass, this may return null if the revision ID is not known (e.g. because the revision does not yet exist in the database).

MCR migration note: this replaces Revision::getId

Returns
int|null

Reimplemented in MediaWiki\Storage\RevisionStoreRecord, and MediaWiki\Storage\RevisionArchiveRecord.

Definition at line 229 of file RevisionRecord.php.

References MediaWiki\Storage\RevisionRecord\$mId.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertSlotCompleteness(), MediaWiki\Storage\RevisionRecord\hasSameContent(), and MediaWiki\Storage\MutableRevisionRecord\newFromParentRevision().

◆ getPageAsLinkTarget()

MediaWiki\Storage\RevisionRecord::getPageAsLinkTarget ( )

Returns the title of the page this revision is associated with as a LinkTarget object.

MCR migration note: this replaces Revision::getTitle

Returns
LinkTarget

Definition at line 301 of file RevisionRecord.php.

References MediaWiki\Storage\RevisionRecord\$mTitle.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual(), and MediaWiki\Storage\MutableRevisionRecord\newFromParentRevision().

◆ getPageId()

◆ getParentId()

MediaWiki\Storage\RevisionRecord::getParentId ( )

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

If there is no parent revision, this returns 0. If the parent revision is undefined or unknown, this returns null.

Note
As of MW 1.31, the database schema allows the parent ID to be NULL to indicate that it is unknown.

MCR migration note: this replaces Revision::getParentId

Returns
int|null

Definition at line 245 of file RevisionRecord.php.

References MediaWiki\Storage\RevisionRecord\$mParentId.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), and MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual().

◆ getSha1()

MediaWiki\Storage\RevisionRecord::getSha1 ( )
abstract

Returns the base36 sha1 of this revision.

This hash is derived from the hashes of all slots associated with the revision. May be calculated on the fly if not known, which may in the worst case may involve loading all content.

MCR migration note: this replaces Revision::getSha1

Exceptions
RevisionAccessExceptionif the hash was unknown and could not be calculated.
Returns
string

Reimplemented in MediaWiki\Storage\RevisionStoreRecord, MediaWiki\Storage\RevisionArchiveRecord, and MediaWiki\Storage\MutableRevisionRecord.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual(), MediaWiki\Storage\RevisionRecord\hasSameContent(), and MediaWiki\Storage\RevisionStore\insertRevisionOn().

◆ getSize()

MediaWiki\Storage\RevisionRecord::getSize ( )
abstract

Returns the nominal size of this revision, in bogo-bytes.

May be calculated on the fly if not known, which may in the worst case may involve loading all content.

MCR migration note: this replaces Revision::getSize

Exceptions
RevisionAccessExceptionif the size was unknown and could not be calculated.
Returns
int

Reimplemented in MediaWiki\Storage\RevisionStoreRecord, MediaWiki\Storage\RevisionArchiveRecord, and MediaWiki\Storage\MutableRevisionRecord.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual(), MediaWiki\Storage\RevisionRecord\hasSameContent(), and MediaWiki\Storage\RevisionStore\insertRevisionOn().

◆ getSlot()

MediaWiki\Storage\RevisionRecord::getSlot (   $role,
  $audience = self::FOR_PUBLIC,
User  $user = null 
)

Returns meta-data for the given slot.

Parameters
string$roleThe role name of the desired slot
int$audience
User | null$user
Exceptions
RevisionAccessExceptionif the slot does not exist or slot data could not be lazy-loaded.
Returns
SlotRecord The slot meta-data. If access to the slot content is forbidden, calling getContent() on the SlotRecord will throw an exception.

Definition at line 189 of file RevisionRecord.php.

References $user, MediaWiki\Storage\RevisionRecord\audienceCan(), and MediaWiki\Storage\SlotRecord\newWithSuppressedContent().

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionCompleteness(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual(), MediaWiki\Storage\RevisionRecord\getContent(), and MediaWiki\Storage\MutableRevisionRecord\newFromParentRevision().

◆ getSlotRoles()

MediaWiki\Storage\RevisionRecord::getSlotRoles ( )

Returns the slot names (roles) of all slots present in this revision.

getContent() will succeed only for the names returned by this method.

Returns
string[]

Definition at line 216 of file RevisionRecord.php.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionCompleteness(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual(), and MediaWiki\Storage\MutableRevisionRecord\newFromParentRevision().

◆ getTimestamp()

MediaWiki\Storage\RevisionRecord::getTimestamp ( )

◆ getUser()

MediaWiki\Storage\RevisionRecord::getUser (   $audience = self::FOR_PUBLIC,
User  $user = null 
)

Fetch revision's author's user identity, if it's available to the specified audience.

If the specified audience does not have access to it, null will be returned. Depending on the concrete subclass, null may also be returned if the user is not yet specified.

MCR migration note: this replaces Revision::getUser

Parameters
int$audienceOne of: RevisionRecord::FOR_PUBLIC to be displayed to all users RevisionRecord::FOR_THIS_USER to be displayed to the given user RevisionRecord::RAW get the ID regardless of permissions
User | null$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
UserIdentity|null

Reimplemented in MediaWiki\Storage\RevisionStoreRecord, and MediaWiki\Storage\RevisionArchiveRecord.

Definition at line 321 of file RevisionRecord.php.

References MediaWiki\Storage\RevisionRecord\$mUser, $user, and MediaWiki\Storage\RevisionRecord\audienceCan().

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision(), MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual(), and MediaWiki\Storage\RevisionStore\insertRevisionOn().

◆ getVisibility()

◆ getWikiId()

MediaWiki\Storage\RevisionRecord::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 290 of file RevisionRecord.php.

References MediaWiki\Storage\RevisionRecord\$mWiki.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual(), and MediaWiki\Storage\MutableRevisionRecord\newFromParentRevision().

◆ hasSameContent()

MediaWiki\Storage\RevisionRecord::hasSameContent ( RevisionRecord  $rec)
Parameters
RevisionRecord$rec
Returns
bool True if this RevisionRecord is known to have same content as $rec. False if the content is different (or not known to be the same).

Definition at line 125 of file RevisionRecord.php.

References MediaWiki\Storage\RevisionRecord\getId(), MediaWiki\Storage\RevisionRecord\getSha1(), and MediaWiki\Storage\RevisionRecord\getSize().

Referenced by MediaWiki\Tests\Storage\testHasSameContent().

◆ hasSlot()

MediaWiki\Storage\RevisionRecord::hasSlot (   $role)

Returns whether the given slot is defined in this revision.

Parameters
string$roleThe role name of the desired slot
Returns
bool

Definition at line 206 of file RevisionRecord.php.

◆ isDeleted()

MediaWiki\Storage\RevisionRecord::isDeleted (   $field)

MCR migration note: this replaces Revision::isDeleted.

Parameters
int$fieldOne of DELETED_* bitfield constants
Returns
bool

Reimplemented in MediaWiki\Storage\RevisionStoreRecord.

Definition at line 370 of file RevisionRecord.php.

References MediaWiki\Storage\RevisionRecord\getVisibility().

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual(), and MediaWiki\Storage\RevisionRecord\audienceCan().

◆ isMinor()

MediaWiki\Storage\RevisionRecord::isMinor ( )

◆ userCan()

MediaWiki\Storage\RevisionRecord::userCan (   $field,
User  $user 
)
protected

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

MCR migration note: this corresponds to Revision::userCan

Parameters
int$fieldOne of self::DELETED_TEXT, self::DELETED_COMMENT, self::DELETED_USER
User$userUser object to check
Returns
bool

Reimplemented in MediaWiki\Storage\RevisionStoreRecord.

Definition at line 443 of file RevisionRecord.php.

References $user, MediaWiki\Storage\RevisionRecord\getVisibility(), and MediaWiki\Storage\RevisionRecord\userCanBitfield().

Referenced by MediaWiki\Storage\RevisionRecord\audienceCan().

◆ userCanBitfield()

static MediaWiki\Storage\RevisionRecord::userCanBitfield (   $bitfield,
  $field,
User  $user,
Title  $title = null 
)
static

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

This is used by various classes to avoid duplication.

MCR migration note: this replaces Revision::userCanBitfield

Parameters
int$bitfieldCurrent field
int$fieldOne of self::DELETED_TEXT = File::DELETED_FILE, self::DELETED_COMMENT = File::DELETED_COMMENT, self::DELETED_USER = File::DELETED_USER
User$userUser object to check
Title | null$titleA Title object to check for per-page restrictions on, instead of just plain userrights
Returns
bool

Definition at line 464 of file RevisionRecord.php.

References $title, $user, as, and wfDebug().

Referenced by MediaWiki\Tests\Storage\testUserCanBitfield(), and MediaWiki\Storage\RevisionRecord\userCan().

Member Data Documentation

◆ $mComment

CommentStoreComment null MediaWiki\Storage\RevisionRecord::$mComment
protected

Definition at line 80 of file RevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionRecord\getComment().

◆ $mDeleted

int MediaWiki\Storage\RevisionRecord::$mDeleted = 0
protected

using the DELETED_XXX and SUPPRESSED_XXX flags

Definition at line 72 of file RevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionRecord\getVisibility().

◆ $mId

int null MediaWiki\Storage\RevisionRecord::$mId
protected

Definition at line 62 of file RevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionRecord\getId().

◆ $mMinorEdit

bool MediaWiki\Storage\RevisionRecord::$mMinorEdit = false
protected

Definition at line 68 of file RevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionRecord\isMinor().

◆ $mPageId

int null MediaWiki\Storage\RevisionRecord::$mPageId
protected

Definition at line 64 of file RevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionRecord\getPageId().

◆ $mParentId

int null MediaWiki\Storage\RevisionRecord::$mParentId
protected

Definition at line 78 of file RevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionRecord\getParentId().

◆ $mSha1

◆ $mSize

int null MediaWiki\Storage\RevisionRecord::$mSize
protected

◆ $mSlots

RevisionSlots MediaWiki\Storage\RevisionRecord::$mSlots
protected

Definition at line 86 of file RevisionRecord.php.

◆ $mTimestamp

string null MediaWiki\Storage\RevisionRecord::$mTimestamp
protected

Definition at line 70 of file RevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionRecord\getTimestamp().

◆ $mTitle

Title MediaWiki\Storage\RevisionRecord::$mTitle
protected

◆ $mUser

UserIdentity null MediaWiki\Storage\RevisionRecord::$mUser
protected

Definition at line 66 of file RevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionRecord\getUser().

◆ $mWiki

string MediaWiki\Storage\RevisionRecord::$mWiki = false
protected

Wiki ID; false means the current wiki.

Definition at line 60 of file RevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionRecord\getWikiId().

◆ DELETED_COMMENT

◆ DELETED_RESTRICTED

◆ DELETED_TEXT

◆ DELETED_USER

◆ FOR_PUBLIC

◆ FOR_THIS_USER

◆ RAW

◆ SUPPRESSED_ALL

const MediaWiki\Storage\RevisionRecord::SUPPRESSED_ALL = 15

Definition at line 52 of file RevisionRecord.php.

Referenced by MediaWiki\Tests\Storage\provideAudienceCheckData().

◆ SUPPRESSED_USER

const MediaWiki\Storage\RevisionRecord::SUPPRESSED_USER = 12

Definition at line 51 of file RevisionRecord.php.


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