MediaWiki REL1_31
MediaWiki\Storage\MutableRevisionRecord Class Reference

Mutable RevisionRecord implementation, for building new revision entries programmatically. More...

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

Public Member Functions

 __construct (Title $title, $wikiId=false)
 
 getSha1 ()
 Returns the base36 sha1 of this revision.
 
 getSize ()
 Returns the nominal size of 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 ( $id)
 Set the revision ID.
 
 setMinorEdit ( $minorEdit)
 
 setPageId ( $pageId)
 
 setParentId ( $parentId)
 
 setSha1 ( $sha1)
 Set revision hash, for optimization.
 
 setSize ( $size)
 Set nominal revision size, for optimization.
 
 setSlot (SlotRecord $slot)
 Sets the given slot.
 
 setTimestamp ( $timestamp)
 
 setUser (UserIdentity $user)
 Sets the user identity associated with the revision.
 
 setVisibility ( $visibility)
 
- Public Member Functions inherited from MediaWiki\Storage\RevisionRecord
 __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).
 
 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 newFromParentRevision (RevisionRecord $parent, CommentStoreComment $comment, UserIdentity $user, $timestamp)
 Returns an incomplete MutableRevisionRecord which uses $parent as its parent revision, and inherits all slots form it.
 
- Static Public Member Functions inherited from MediaWiki\Storage\RevisionRecord
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.
 

Private Member Functions

 resetAggregateValues ()
 Invalidate cached aggregate values such as hash and size.
 

Additional Inherited Members

- Public Attributes inherited from MediaWiki\Storage\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 = 15
 
const SUPPRESSED_USER = 12
 
- Protected Member Functions inherited from MediaWiki\Storage\RevisionRecord
 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 inherited from MediaWiki\Storage\RevisionRecord
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.
 

Detailed Description

Mutable RevisionRecord implementation, for building new revision entries programmatically.

Provides setters for all fields.

Since
1.31

Definition at line 39 of file MutableRevisionRecord.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\MutableRevisionRecord::__construct ( Title  $title,
  $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.
bool | string$wikiIdthe wiki ID of the site this Revision belongs to, or false for the local site.
Exceptions
MWException

Definition at line 88 of file MutableRevisionRecord.php.

References $title.

Member Function Documentation

◆ getSha1()

MediaWiki\Storage\MutableRevisionRecord::getSha1 ( )

Returns the base36 sha1 of this revision.

MCR migration note: this replaces Revision::getSha1

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

Reimplemented from MediaWiki\Storage\RevisionRecord.

Definition at line 311 of file MutableRevisionRecord.php.

References MediaWiki\Storage\RevisionRecord\$mSha1.

◆ getSize()

MediaWiki\Storage\MutableRevisionRecord::getSize ( )

Returns the nominal size of this revision.

MCR migration note: this replaces Revision::getSize

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

Reimplemented from MediaWiki\Storage\RevisionRecord.

Definition at line 295 of file MutableRevisionRecord.php.

References MediaWiki\Storage\RevisionRecord\$mSize.

◆ inheritSlot()

MediaWiki\Storage\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

Definition at line 142 of file MutableRevisionRecord.php.

References MediaWiki\Storage\SlotRecord\newInherited(), and MediaWiki\Storage\MutableRevisionRecord\setSlot().

◆ newFromParentRevision()

static MediaWiki\Storage\MutableRevisionRecord::newFromParentRevision ( RevisionRecord  $parent,
CommentStoreComment  $comment,
UserIdentity  $user,
  $timestamp 
)
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
CommentStoreComment$comment
UserIdentity$user
string$timestamp
Returns
MutableRevisionRecord

Definition at line 53 of file MutableRevisionRecord.php.

References $rev, $title, $user, as, MediaWiki\Storage\RevisionRecord\getId(), MediaWiki\Storage\RevisionRecord\getPageAsLinkTarget(), MediaWiki\Storage\RevisionRecord\getPageId(), MediaWiki\Storage\RevisionRecord\getSlot(), MediaWiki\Storage\RevisionRecord\getSlotRoles(), and MediaWiki\Storage\RevisionRecord\getWikiId().

◆ removeSlot()

MediaWiki\Storage\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

Definition at line 178 of file MutableRevisionRecord.php.

References MediaWiki\Storage\MutableRevisionRecord\resetAggregateValues().

◆ resetAggregateValues()

MediaWiki\Storage\MutableRevisionRecord::resetAggregateValues ( )
private

◆ setComment()

MediaWiki\Storage\MutableRevisionRecord::setComment ( CommentStoreComment  $comment)

◆ setContent()

MediaWiki\Storage\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

Definition at line 161 of file MutableRevisionRecord.php.

References MediaWiki\Storage\MutableRevisionRecord\resetAggregateValues().

◆ setId()

MediaWiki\Storage\MutableRevisionRecord::setId (   $id)

Set the revision ID.

MCR migration note: this replaces 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

Definition at line 258 of file MutableRevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray().

◆ setMinorEdit()

MediaWiki\Storage\MutableRevisionRecord::setMinorEdit (   $minorEdit)
Parameters
bool$minorEdit

Definition at line 241 of file MutableRevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray().

◆ setPageId()

MediaWiki\Storage\MutableRevisionRecord::setPageId (   $pageId)
Parameters
int$pageId

Definition at line 276 of file MutableRevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray().

◆ setParentId()

MediaWiki\Storage\MutableRevisionRecord::setParentId (   $parentId)
Parameters
int$parentId

Definition at line 99 of file MutableRevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray().

◆ setSha1()

MediaWiki\Storage\MutableRevisionRecord::setSha1 (   $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.

Definition at line 199 of file MutableRevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray().

◆ setSize()

MediaWiki\Storage\MutableRevisionRecord::setSize (   $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

Definition at line 214 of file MutableRevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray().

◆ setSlot()

MediaWiki\Storage\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

Definition at line 120 of file MutableRevisionRecord.php.

References MediaWiki\Storage\SlotRecord\getRevision(), MediaWiki\Storage\SlotRecord\hasRevision(), and MediaWiki\Storage\MutableRevisionRecord\resetAggregateValues().

Referenced by MediaWiki\Storage\MutableRevisionRecord\inheritSlot().

◆ setTimestamp()

MediaWiki\Storage\MutableRevisionRecord::setTimestamp (   $timestamp)
Parameters
string$timestampA timestamp understood by wfTimestamp

Definition at line 232 of file MutableRevisionRecord.php.

References wfTimestamp().

Referenced by MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray().

◆ setUser()

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

Sets the user identity associated with the revision.

Parameters
UserIdentity$user

Definition at line 269 of file MutableRevisionRecord.php.

References $user.

Referenced by MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray().

◆ setVisibility()

MediaWiki\Storage\MutableRevisionRecord::setVisibility (   $visibility)
Parameters
int$visibility

Definition at line 223 of file MutableRevisionRecord.php.

Referenced by MediaWiki\Storage\RevisionStore\initializeMutableRevisionFromArray().


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