MediaWiki master
MediaWiki\Revision\MutableRevisionRecord Class Reference

Inherits MediaWiki\Revision\RevisionRecord.

Collaboration diagram for MediaWiki\Revision\MutableRevisionRecord:

Public Member Functions

 __construct (PageIdentity $page, $wikiId=self::LOCAL)
 
 applyUpdate (RevisionSlotsUpdate $update)
 Applies the given update to the slots of this revision.
 
 getSha1 ()
 Returns the base36 sha1 of this revision.
 
 getSize ()
 Returns the nominal size of this revision.
 
 getSlots ()
 Returns the slots defined for this revision as a MutableRevisionSlots instance, which can be modified to defined the slots for this revision.
 
 inheritSlot (SlotRecord $parentSlot)
 "Inherits" the given slot's content.
 
 removeSlot ( $role)
 Removes the slot with the given role from this revision.
 
 setComment (CommentStoreComment $comment)
 
 setContent ( $role, Content $content)
 Sets the content for the slot with the given role.
 
 setId (int $id)
 Set the revision ID.
 
 setMinorEdit (bool $minorEdit)
 
 setPageId (int $pageId)
 
 setParentId (int $parentId)
 
 setSha1 (string $sha1)
 Set revision hash, for optimization.
 
 setSize (int $size)
 Set nominal revision size, for optimization.
 
 setSlot (SlotRecord $slot)
 Sets the given slot.
 
 setTimestamp (string $timestamp)
 
 setUser (UserIdentity $user)
 Sets the user identity associated with the revision.
 
 setVisibility (int $visibility)
 
- Public Member Functions inherited from MediaWiki\Revision\RevisionRecord
 __construct (PageIdentity $page, RevisionSlots $slots, $wikiId=self::LOCAL)
 
 audienceCan ( $field, $audience, Authority $performer=null)
 Check that the given audience has access to the given field.
 
 getComment ( $audience=self::FOR_PUBLIC, Authority $performer=null)
 Fetch revision comment, if it's available to the specified audience.
 
 getContent ( $role, $audience=self::FOR_PUBLIC, Authority $performer=null)
 Returns the Content of the given slot of this revision.
 
 getContentOrThrow ( $role, $audience=self::FOR_PUBLIC, Authority $performer=null)
 Get the Content of the given slot of this revision.
 
 getId ( $wikiId=self::LOCAL)
 Get revision ID.
 
 getInheritedSlots ()
 Returns slots inherited from some previous revision.
 
 getOriginalSlots ()
 Returns the slots that originate in this revision.
 
 getPage ()
 Returns the page this revision belongs to.
 
 getPageAsLinkTarget ()
 Returns the title of the page this revision is associated with as a LinkTarget object.
 
 getPageId ( $wikiId=self::LOCAL)
 Get the page ID.
 
 getParentId ( $wikiId=self::LOCAL)
 Get parent revision ID (the original previous page revision).
 
 getPrimarySlots ()
 Returns primary slots (those that are not derived).
 
 getSlot ( $role, $audience=self::FOR_PUBLIC, Authority $performer=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 replaced Revision::getTimestamp.
 
 getUser ( $audience=self::FOR_PUBLIC, Authority $performer=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.
 
 isCurrent ()
 Checks whether the revision record is a stored current revision.
 
 isDeleted ( $field)
 MCR migration note: this replaced Revision::isDeleted.
 
 isMinor ()
 MCR migration note: this replaced Revision::isMinor.
 
 isReadyForInsertion ()
 Returns whether this RevisionRecord is ready for insertion, that is, whether it contains all information needed to save it to the database.
 
 userCan ( $field, Authority $performer)
 Determine if the give authority is allowed to view a particular field of this revision, if it's marked as deleted.
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId().
 

Static Public Member Functions

static newFromParentRevision (RevisionRecord $parent)
 Returns an incomplete MutableRevisionRecord which uses $parent as its parent revision, and inherits all slots form it.
 
static newUpdatedRevisionRecord (RevisionRecord $revision, array $slots)
 Returns a MutableRevisionRecord which is an updated version of $revision with $slots added.
 
- Static Public Member Functions inherited from MediaWiki\Revision\RevisionRecord
static userCanBitfield ( $bitfield, $field, Authority $performer, PageIdentity $page=null)
 Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted.
 

Additional Inherited Members

- Public Attributes inherited from MediaWiki\Revision\RevisionRecord
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
 
const SUPPRESSED_USER = self::DELETED_USER | self::DELETED_RESTRICTED
 
- Protected Attributes inherited from MediaWiki\Revision\RevisionRecord
CommentStoreComment null $mComment
 
int $mDeleted = 0
 using the DELETED_XXX and SUPPRESSED_XXX flags
 
int null $mId
 
bool $mMinorEdit = false
 
PageIdentity $mPage
 
int $mPageId
 
int null $mParentId
 
string null $mSha1
 
int null $mSize
 
RevisionSlots $mSlots
 
string null $mTimestamp
 
UserIdentity null $mUser
 
string false $wikiId = false
 Wiki ID; false means the current wiki.
 

Detailed Description

Definition at line 43 of file MutableRevisionRecord.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Revision\MutableRevisionRecord::__construct ( PageIdentity  $page,
  $wikiId = self::LOCAL 
)
Stability: stable
to call.
Parameters
PageIdentity$pageThe page this RevisionRecord is associated with.
false | string$wikiIdRelevant wiki id or self::LOCAL for the current one.

Definition at line 107 of file MutableRevisionRecord.php.

Member Function Documentation

◆ applyUpdate()

MediaWiki\Revision\MutableRevisionRecord::applyUpdate ( RevisionSlotsUpdate  $update)

Applies the given update to the slots of this revision.

Parameters
RevisionSlotsUpdate$update
Returns
self

Definition at line 217 of file MutableRevisionRecord.php.

References MediaWiki\Storage\RevisionSlotsUpdate\apply().

◆ getSha1()

MediaWiki\Revision\MutableRevisionRecord::getSha1 ( )

Returns the base36 sha1 of this revision.

MCR migration note: this replaced Revision::getSha1

Returns
string The revision hash, may be computed on the fly if not yet known.

Reimplemented from MediaWiki\Revision\RevisionRecord.

Definition at line 363 of file MutableRevisionRecord.php.

◆ getSize()

MediaWiki\Revision\MutableRevisionRecord::getSize ( )

Returns the nominal size of this revision.

MCR migration note: this replaced Revision::getSize

Returns
int The nominal size, may be computed on the fly if not yet known.

Reimplemented from MediaWiki\Revision\RevisionRecord.

Definition at line 349 of file MutableRevisionRecord.php.

◆ getSlots()

MediaWiki\Revision\MutableRevisionRecord::getSlots ( )

Returns the slots defined for this revision as a MutableRevisionSlots instance, which can be modified to defined the slots for this revision.

Returns
MutableRevisionSlots

Reimplemented from MediaWiki\Revision\RevisionRecord.

Definition at line 376 of file MutableRevisionRecord.php.

◆ inheritSlot()

MediaWiki\Revision\MutableRevisionRecord::inheritSlot ( SlotRecord  $parentSlot)

"Inherits" the given slot's content.

If a slot with the same role is already present in the revision, it is replaced.

Note
This may cause the slot meta-data for the revision to be lazy-loaded.
Parameters
SlotRecord$parentSlot
Returns
self

Definition at line 165 of file MutableRevisionRecord.php.

◆ newFromParentRevision()

static MediaWiki\Revision\MutableRevisionRecord::newFromParentRevision ( RevisionRecord  $parent)
static

Returns an incomplete MutableRevisionRecord which uses $parent as its parent revision, and inherits all slots form it.

If saved unchanged, the new revision will act as a null-revision.

Parameters
RevisionRecord$parent
Returns
MutableRevisionRecord

Definition at line 54 of file MutableRevisionRecord.php.

References MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\Revision\RevisionRecord\getPage(), MediaWiki\Revision\RevisionRecord\getPageId(), MediaWiki\Revision\RevisionRecord\getSlot(), MediaWiki\Revision\RevisionRecord\getSlotRoles(), and MediaWiki\Revision\RevisionRecord\getWikiId().

◆ newUpdatedRevisionRecord()

static MediaWiki\Revision\MutableRevisionRecord::newUpdatedRevisionRecord ( RevisionRecord  $revision,
array  $slots 
)
static

Returns a MutableRevisionRecord which is an updated version of $revision with $slots added.

Parameters
RevisionRecord$revision
SlotRecord[]$slots
Returns
MutableRevisionRecord
Since
1.36

Definition at line 76 of file MutableRevisionRecord.php.

◆ removeSlot()

MediaWiki\Revision\MutableRevisionRecord::removeSlot (   $role)

Removes the slot with the given role from this revision.

This effectively ends the "stream" with that role on the revision's page. Future revisions will no longer inherit this slot, unless it is added back explicitly.

Note
This may cause the slot meta-data for the revision to be lazy-loaded.
Calling this method will cause the revision size and hash to be re-calculated upon the next call to getSize() and getSha1(), respectively.
Parameters
string$role
Returns
self

Definition at line 205 of file MutableRevisionRecord.php.

◆ setComment()

MediaWiki\Revision\MutableRevisionRecord::setComment ( CommentStoreComment  $comment)
Parameters
CommentStoreComment$comment
Returns
self

Definition at line 227 of file MutableRevisionRecord.php.

◆ setContent()

MediaWiki\Revision\MutableRevisionRecord::setContent (   $role,
Content  $content 
)

Sets the content for the slot with the given role.

If a slot with the same role is already present in the revision, it is replaced. Calling code that has access to a SlotRecord can use inheritSlot() instead.

Note
This may cause the slot meta-data for the revision to be lazy-loaded.
Calling this method will cause the revision size and hash to be re-calculated upon the next call to getSize() and getSha1(), respectively.
Parameters
string$role
Content$content
Returns
self

Definition at line 186 of file MutableRevisionRecord.php.

Referenced by ApiComparePages\execute().

◆ setId()

MediaWiki\Revision\MutableRevisionRecord::setId ( int  $id)

Set the revision ID.

MCR migration note: this replaced Revision::setId

Warning
Use this with care, especially when preparing a revision for insertion into the database! The revision ID should only be fixed in special cases like preserving the original ID when restoring a revision.
Parameters
int$id
Returns
self

Definition at line 307 of file MutableRevisionRecord.php.

◆ setMinorEdit()

MediaWiki\Revision\MutableRevisionRecord::setMinorEdit ( bool  $minorEdit)
Parameters
bool$minorEdit
Returns
self

Definition at line 289 of file MutableRevisionRecord.php.

◆ setPageId()

MediaWiki\Revision\MutableRevisionRecord::setPageId ( int  $pageId)
Parameters
int$pageId
Returns
self

Definition at line 329 of file MutableRevisionRecord.php.

◆ setParentId()

MediaWiki\Revision\MutableRevisionRecord::setParentId ( int  $parentId)
Parameters
int$parentId
Returns
self

Definition at line 119 of file MutableRevisionRecord.php.

◆ setSha1()

MediaWiki\Revision\MutableRevisionRecord::setSha1 ( string  $sha1)

Set revision hash, for optimization.

Prevents getSha1() from re-calculating the hash.

Note
This should only be used if the calling code is sure that the given hash is correct for the revision's content, and there is no chance of the content being manipulated later. When in doubt, this method should not be called.
Parameters
string$sha1SHA1 hash as a base36 string.
Returns
self

Definition at line 243 of file MutableRevisionRecord.php.

◆ setSize()

MediaWiki\Revision\MutableRevisionRecord::setSize ( int  $size)

Set nominal revision size, for optimization.

Prevents getSize() from re-calculating the size.

Note
This should only be used if the calling code is sure that the given size is correct for the revision's content, and there is no chance of the content being manipulated later. When in doubt, this method should not be called.
Parameters
int$sizenominal size in bogo-bytes
Returns
self

Definition at line 259 of file MutableRevisionRecord.php.

◆ setSlot()

MediaWiki\Revision\MutableRevisionRecord::setSlot ( SlotRecord  $slot)

Sets the given slot.

If a slot with the same role is already present in the revision, it is replaced.

Note
This can only be used with a fresh "unattached" SlotRecord. Calling code that has a SlotRecord from another revision should use inheritSlot(). Calling code that has access to a Content object can use setContent().
This may cause the slot meta-data for the revision to be lazy-loaded.
Calling this method will cause the revision size and hash to be re-calculated upon the next call to getSize() and getSha1(), respectively.
Parameters
SlotRecord$slot
Returns
self

Definition at line 141 of file MutableRevisionRecord.php.

References MediaWiki\Revision\SlotRecord\getRevision(), and MediaWiki\Revision\SlotRecord\hasRevision().

◆ setTimestamp()

MediaWiki\Revision\MutableRevisionRecord::setTimestamp ( string  $timestamp)
Parameters
string$timestampA timestamp understood by MWTimestamp
Returns
self

Definition at line 279 of file MutableRevisionRecord.php.

◆ setUser()

MediaWiki\Revision\MutableRevisionRecord::setUser ( UserIdentity  $user)

Sets the user identity associated with the revision.

Parameters
UserIdentity$user
Returns
self

Definition at line 319 of file MutableRevisionRecord.php.

◆ setVisibility()

MediaWiki\Revision\MutableRevisionRecord::setVisibility ( int  $visibility)
Parameters
int$visibility
Returns
self

Definition at line 269 of file MutableRevisionRecord.php.


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