MediaWiki REL1_31
|
Page revision base class. More...
Public Member Functions | |
__construct (Title $title, RevisionSlots $slots, $wikiId=false) | |
__sleep () | |
Implemented to defy serialization. | |
getComment ( $audience=self::FOR_PUBLIC, User $user=null) | |
Fetch revision comment, if it's available to the specified audience. | |
getContent ( $role, $audience=self::FOR_PUBLIC, User $user=null) | |
Returns the Content of the given slot of this revision. | |
getId () | |
Get revision ID. | |
getPageAsLinkTarget () | |
Returns the title of the page this revision is associated with as a LinkTarget object. | |
getPageId () | |
Get the page ID. | |
getParentId () | |
Get parent revision ID (the original previous page revision). | |
getSha1 () | |
Returns the base36 sha1 of this revision. | |
getSize () | |
Returns the nominal size of this revision, in bogo-bytes. | |
getSlot ( $role, $audience=self::FOR_PUBLIC, User $user=null) | |
Returns meta-data for the given slot. | |
getSlotRoles () | |
Returns the slot names (roles) of all slots present in this revision. | |
getTimestamp () | |
MCR migration note: this replaces Revision::getTimestamp. | |
getUser ( $audience=self::FOR_PUBLIC, User $user=null) | |
Fetch revision's author's user identity, if it's available to the specified audience. | |
getVisibility () | |
Get the deletion bitfield of the revision. | |
getWikiId () | |
Get the ID of the wiki this revision belongs to. | |
hasSameContent (RevisionRecord $rec) | |
hasSlot ( $role) | |
Returns whether the given slot is defined in this revision. | |
isDeleted ( $field) | |
MCR migration note: this replaces Revision::isDeleted. | |
isMinor () | |
MCR migration note: this replaces Revision::isMinor. | |
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. | |
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. | |
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. | |
Protected Attributes | |
CommentStoreComment null | $mComment |
int | $mDeleted = 0 |
using the DELETED_XXX and SUPPRESSED_XXX flags | |
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. | |
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.
Definition at line 44 of file RevisionRecord.php.
MediaWiki\Storage\RevisionRecord::__construct | ( | Title | $title, |
RevisionSlots | $slots, | ||
$wikiId = false ) |
Title | $title | The title of the page this Revision is associated with. |
RevisionSlots | $slots | The slots of this revision. |
bool | string | $wikiId | the wiki ID of the site this Revision belongs to, or false for the local site. |
MWException |
Definition at line 99 of file RevisionRecord.php.
References $title.
MediaWiki\Storage\RevisionRecord::__sleep | ( | ) |
Implemented to defy serialization.
LogicException | always |
Definition at line 115 of file RevisionRecord.php.
|
protected |
Check that the given audience has access to the given field.
MCR migration note: this corresponds to Revision::userCan
int | $field | One of self::DELETED_TEXT, self::DELETED_COMMENT, self::DELETED_USER |
int | $audience | One 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 | $user | User object to check. Required if $audience is FOR_THIS_USER, ignored otherwise. |
Definition at line 413 of file RevisionRecord.php.
References 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().
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
int | $audience | One 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 | $user | User object to check for, only if FOR_THIS_USER is passed to the $audience parameter |
Reimplemented in MediaWiki\Storage\RevisionArchiveRecord, and MediaWiki\Storage\RevisionStoreRecord.
Definition at line 346 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\$mComment, and MediaWiki\Storage\RevisionRecord\audienceCan().
Referenced by MediaWiki\Storage\RevisionStore\insertRevisionOn().
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
string | $role | The role name of the desired slot |
int | $audience | |
User | null | $user |
RevisionAccessException | if the slot does not exist or slot data could not be lazy-loaded. |
Definition at line 165 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\audienceCan(), and MediaWiki\Storage\RevisionRecord\getSlot().
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
Reimplemented in MediaWiki\Storage\RevisionArchiveRecord, and MediaWiki\Storage\RevisionStoreRecord.
Definition at line 229 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\$mId.
Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertSlotCompleteness(), MediaWiki\Storage\RevisionRecord\hasSameContent(), and MediaWiki\Storage\MutableRevisionRecord\newFromParentRevision().
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
Definition at line 301 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\$mTitle.
Referenced by MediaWiki\Storage\MutableRevisionRecord\newFromParentRevision().
MediaWiki\Storage\RevisionRecord::getPageId | ( | ) |
Get the page ID.
If the page does not yet exist, the page ID is 0.
MCR migration note: this replaces Revision::getPage
Definition at line 281 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\$mPageId.
Referenced by MediaWiki\Storage\RevisionStore\getNextRevision(), MediaWiki\Storage\RevisionStore\getPreviousRevision(), MediaWiki\Storage\RevisionStore\insertRevisionOn(), and MediaWiki\Storage\MutableRevisionRecord\newFromParentRevision().
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.
MCR migration note: this replaces Revision::getParentId
Definition at line 245 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\$mParentId.
|
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
RevisionAccessException | if the hash was unknown and could not be calculated. |
Reimplemented in MediaWiki\Storage\MutableRevisionRecord, MediaWiki\Storage\RevisionArchiveRecord, and MediaWiki\Storage\RevisionStoreRecord.
Referenced by MediaWiki\Storage\RevisionRecord\hasSameContent(), and MediaWiki\Storage\RevisionStore\insertRevisionOn().
|
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
RevisionAccessException | if the size was unknown and could not be calculated. |
Reimplemented in MediaWiki\Storage\MutableRevisionRecord, MediaWiki\Storage\RevisionArchiveRecord, and MediaWiki\Storage\RevisionStoreRecord.
Referenced by MediaWiki\Storage\RevisionRecord\hasSameContent(), and MediaWiki\Storage\RevisionStore\insertRevisionOn().
MediaWiki\Storage\RevisionRecord::getSlot | ( | $role, | |
$audience = self::FOR_PUBLIC, | |||
User | $user = null ) |
Returns meta-data for the given slot.
string | $role | The role name of the desired slot |
int | $audience | |
User | null | $user |
RevisionAccessException | if the slot does not exist or slot data could not be lazy-loaded. |
Definition at line 189 of file RevisionRecord.php.
References 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().
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.
Definition at line 216 of file RevisionRecord.php.
Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionCompleteness(), and MediaWiki\Storage\MutableRevisionRecord\newFromParentRevision().
MediaWiki\Storage\RevisionRecord::getTimestamp | ( | ) |
MCR migration note: this replaces Revision::getTimestamp.
May return null if the timestamp was not specified.
Reimplemented in MediaWiki\Storage\RevisionArchiveRecord, and MediaWiki\Storage\RevisionStoreRecord.
Definition at line 392 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\$mTimestamp.
Referenced by MediaWiki\Storage\RevisionStore\insertRevisionOn().
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
int | $audience | One 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 | $user | User object to check for, only if FOR_THIS_USER is passed to the $audience parameter |
Reimplemented in MediaWiki\Storage\RevisionArchiveRecord, and MediaWiki\Storage\RevisionStoreRecord.
Definition at line 321 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\$mUser, and MediaWiki\Storage\RevisionRecord\audienceCan().
Referenced by MediaWiki\Storage\RevisionStore\insertRevisionOn().
MediaWiki\Storage\RevisionRecord::getVisibility | ( | ) |
Get the deletion bitfield of the revision.
MCR migration note: this replaces Revision::getVisibility
Definition at line 381 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\$mDeleted.
Referenced by MediaWiki\Storage\RevisionRecord\isDeleted(), and MediaWiki\Storage\RevisionRecord\userCan().
MediaWiki\Storage\RevisionRecord::getWikiId | ( | ) |
Get the ID of the wiki this revision belongs to.
Definition at line 290 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\$mWiki.
Referenced by MediaWiki\Storage\MutableRevisionRecord\newFromParentRevision().
MediaWiki\Storage\RevisionRecord::hasSameContent | ( | RevisionRecord | $rec | ) |
RevisionRecord | $rec |
Definition at line 125 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\getId(), MediaWiki\Storage\RevisionRecord\getSha1(), and MediaWiki\Storage\RevisionRecord\getSize().
MediaWiki\Storage\RevisionRecord::hasSlot | ( | $role | ) |
Returns whether the given slot is defined in this revision.
string | $role | The role name of the desired slot |
Definition at line 206 of file RevisionRecord.php.
MediaWiki\Storage\RevisionRecord::isDeleted | ( | $field | ) |
MCR migration note: this replaces Revision::isDeleted.
int | $field | One of DELETED_* bitfield constants |
Reimplemented in MediaWiki\Storage\RevisionStoreRecord.
Definition at line 370 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\getVisibility().
Referenced by MediaWiki\Storage\RevisionRecord\audienceCan().
MediaWiki\Storage\RevisionRecord::isMinor | ( | ) |
MCR migration note: this replaces Revision::isMinor.
Definition at line 359 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\$mMinorEdit.
|
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
int | $field | One of self::DELETED_TEXT, self::DELETED_COMMENT, self::DELETED_USER |
User | $user | User object to check |
Reimplemented in MediaWiki\Storage\RevisionStoreRecord.
Definition at line 443 of file RevisionRecord.php.
References MediaWiki\Storage\RevisionRecord\getVisibility(), and MediaWiki\Storage\RevisionRecord\userCanBitfield().
Referenced by MediaWiki\Storage\RevisionRecord\audienceCan().
|
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
int | $bitfield | Current field |
int | $field | One of self::DELETED_TEXT = File::DELETED_FILE, self::DELETED_COMMENT = File::DELETED_COMMENT, self::DELETED_USER = File::DELETED_USER |
User | $user | User object to check |
Title | null | $title | A Title object to check for per-page restrictions on, instead of just plain userrights |
Definition at line 464 of file RevisionRecord.php.
References wfDebug().
Referenced by MediaWiki\Storage\RevisionRecord\userCan().
|
protected |
Definition at line 80 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionRecord\getComment().
|
protected |
using the DELETED_XXX and SUPPRESSED_XXX flags
Definition at line 72 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionRecord\getVisibility().
|
protected |
Definition at line 62 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionRecord\getId().
|
protected |
Definition at line 68 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionRecord\isMinor().
|
protected |
Definition at line 64 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionRecord\getPageId().
|
protected |
Definition at line 78 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionRecord\getParentId().
|
protected |
Definition at line 76 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\MutableRevisionRecord\getSha1(), MediaWiki\Storage\RevisionArchiveRecord\getSha1(), and MediaWiki\Storage\RevisionStoreRecord\getSha1().
|
protected |
Definition at line 74 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\MutableRevisionRecord\getSize(), MediaWiki\Storage\RevisionArchiveRecord\getSize(), and MediaWiki\Storage\RevisionStoreRecord\getSize().
|
protected |
Definition at line 86 of file RevisionRecord.php.
|
protected |
Definition at line 70 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionRecord\getTimestamp().
|
protected |
Definition at line 83 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionRecord\getPageAsLinkTarget().
|
protected |
Definition at line 66 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionRecord\getUser().
|
protected |
Wiki ID; false means the current wiki.
Definition at line 60 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionRecord\getWikiId().
const MediaWiki\Storage\RevisionRecord::DELETED_COMMENT = 2 |
Definition at line 48 of file RevisionRecord.php.
const MediaWiki\Storage\RevisionRecord::DELETED_RESTRICTED = 8 |
Definition at line 50 of file RevisionRecord.php.
const MediaWiki\Storage\RevisionRecord::DELETED_TEXT = 1 |
Definition at line 47 of file RevisionRecord.php.
const MediaWiki\Storage\RevisionRecord::DELETED_USER = 4 |
Definition at line 49 of file RevisionRecord.php.
const MediaWiki\Storage\RevisionRecord::FOR_PUBLIC = 1 |
Definition at line 55 of file RevisionRecord.php.
const MediaWiki\Storage\RevisionRecord::FOR_THIS_USER = 2 |
Definition at line 56 of file RevisionRecord.php.
const MediaWiki\Storage\RevisionRecord::RAW = 3 |
Definition at line 57 of file RevisionRecord.php.
Referenced by MediaWiki\Storage\RevisionStore\getRecentChange(), and MediaWiki\Storage\RevisionStore\insertRevisionOn().
const MediaWiki\Storage\RevisionRecord::SUPPRESSED_ALL = 15 |
Definition at line 52 of file RevisionRecord.php.
const MediaWiki\Storage\RevisionRecord::SUPPRESSED_USER = 12 |
Definition at line 51 of file RevisionRecord.php.