MediaWiki  master
Revision\MutableRevisionRecord Class Reference

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

Inheritance diagram for Revision\MutableRevisionRecord:
Collaboration diagram for Revision\MutableRevisionRecord:

Public Member Functions

 __construct (Title $title, $dbDomain=false)
 
 applyUpdate (RevisionSlotsUpdate $update)
 Applies the given update to the slots of this revision. More...
 
 getSha1 ()
 Returns the base36 sha1 of this revision. More...
 
 getSize ()
 Returns the nominal size of this revision. More...
 
 getSlots ()
 Returns the slots defined for this revision as a MutableRevisionSlots instance, which can be modified to defined the slots for this revision. More...
 
 inheritSlot (SlotRecord $parentSlot)
 "Inherits" the given slot's content. More...
 
 removeSlot ( $role)
 Removes the slot with the given role from this revision. More...
 
 setComment (CommentStoreComment $comment)
 
 setContent ( $role, Content $content)
 Sets the content for the slot with the given role. More...
 
 setId ( $id)
 Set the revision ID. More...
 
 setMinorEdit ( $minorEdit)
 
 setPageId ( $pageId)
 
 setParentId ( $parentId)
 
 setSha1 ( $sha1)
 Set revision hash, for optimization. More...
 
 setSize ( $size)
 Set nominal revision size, for optimization. More...
 
 setSlot (SlotRecord $slot)
 Sets the given slot. More...
 
 setTimestamp ( $timestamp)
 
 setUser (UserIdentity $user)
 Sets the user identity associated with the revision. More...
 
 setVisibility ( $visibility)
 
- Public Member Functions inherited from Revision\RevisionRecord
 __construct (Title $title, RevisionSlots $slots, $dbDomain=false)
 
 __sleep ()
 Implemented to defy serialization. More...
 
 audienceCan ( $field, $audience, User $user=null)
 Check that the given audience has access to the given field. 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...
 
 getInheritedSlots ()
 Returns slots inherited from some previous revision. More...
 
 getOriginalSlots ()
 Returns the slots that originate in this revision. 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...
 
 getSlots ()
 Returns the slots defined for 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...
 
 isReadyForInsertion ()
 Returns whether this RevisionRecord is ready for insertion, that is, whether it contains all information needed to save it to the database. More...
 

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. More...
 
- Static Public Member Functions inherited from Revision\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. More...
 

Private Member Functions

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

Additional Inherited Members

- Public Attributes inherited from 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 Member Functions inherited from Revision\RevisionRecord
 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 inherited from Revision\RevisionRecord
CommentStoreComment null $mComment
 
int $mDeleted = 0
 using the DELETED_XXX and SUPPRESSED_XXX flags More...
 
int null $mId
 
bool $mMinorEdit = false
 
int $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

Mutable RevisionRecord implementation, for building new revision entries programmatically.

Provides setters for all fields.

Since
1.31
1.32 Renamed from MediaWiki\Storage\MutableRevisionRecord

Definition at line 41 of file MutableRevisionRecord.php.

Constructor & Destructor Documentation

◆ __construct()

Revision\MutableRevisionRecord::__construct ( Title  $title,
  $dbDomain = 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$dbDomainDB domain of the relevant wiki or false for the current one.
Exceptions
MWException

Definition at line 77 of file MutableRevisionRecord.php.

Member Function Documentation

◆ applyUpdate()

Revision\MutableRevisionRecord::applyUpdate ( RevisionSlotsUpdate  $update)

Applies the given update to the slots of this revision.

Parameters
RevisionSlotsUpdate$update

Definition at line 177 of file MutableRevisionRecord.php.

◆ getSha1()

Revision\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.

Definition at line 309 of file MutableRevisionRecord.php.

References Revision\RevisionRecord\$mSha1, and null.

◆ getSize()

Revision\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.

Definition at line 293 of file MutableRevisionRecord.php.

References Revision\RevisionRecord\$mSize, and null.

◆ getSlots()

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

Definition at line 324 of file MutableRevisionRecord.php.

◆ inheritSlot()

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

Definition at line 131 of file MutableRevisionRecord.php.

References Revision\MutableRevisionRecord\resetAggregateValues().

◆ newFromParentRevision()

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

◆ removeSlot()

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

Definition at line 167 of file MutableRevisionRecord.php.

References Revision\MutableRevisionRecord\resetAggregateValues().

◆ resetAggregateValues()

Revision\MutableRevisionRecord::resetAggregateValues ( )
private

◆ setComment()

Revision\MutableRevisionRecord::setComment ( CommentStoreComment  $comment)

◆ setContent()

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

Definition at line 150 of file MutableRevisionRecord.php.

References Revision\MutableRevisionRecord\resetAggregateValues().

◆ setId()

Revision\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 256 of file MutableRevisionRecord.php.

Referenced by PoolWorkArticleView\__construct(), Revision\RevisionStore\initializeMutableRevisionFromArray(), RevisionDbTestBase\provideGetTextId(), PoolWorkArticleViewTest\testDoWorkDeletedContent(), and PoolWorkArticleViewTest\testDoWorkWithExplicitRevision().

◆ setMinorEdit()

Revision\MutableRevisionRecord::setMinorEdit (   $minorEdit)
Parameters
bool$minorEdit

Definition at line 239 of file MutableRevisionRecord.php.

Referenced by Revision\RevisionStore\initializeMutableRevisionFromArray().

◆ setPageId()

Revision\MutableRevisionRecord::setPageId (   $pageId)
Parameters
int$pageId

Definition at line 274 of file MutableRevisionRecord.php.

Referenced by Revision\RevisionStore\initializeMutableRevisionFromArray().

◆ setParentId()

Revision\MutableRevisionRecord::setParentId (   $parentId)
Parameters
int$parentId

Definition at line 88 of file MutableRevisionRecord.php.

Referenced by Revision\RevisionStore\initializeMutableRevisionFromArray().

◆ setSha1()

Revision\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 197 of file MutableRevisionRecord.php.

Referenced by Revision\RevisionStore\initializeMutableRevisionFromArray().

◆ setSize()

Revision\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 212 of file MutableRevisionRecord.php.

Referenced by Revision\RevisionStore\initializeMutableRevisionFromArray().

◆ setSlot()

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

Definition at line 109 of file MutableRevisionRecord.php.

References Revision\RevisionRecord\getId(), Revision\SlotRecord\getRevision(), Revision\SlotRecord\hasRevision(), and Revision\MutableRevisionRecord\resetAggregateValues().

◆ setTimestamp()

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

Definition at line 230 of file MutableRevisionRecord.php.

References wfTimestamp().

Referenced by Revision\RevisionStore\initializeMutableRevisionFromArray().

◆ setUser()

Revision\MutableRevisionRecord::setUser ( UserIdentity  $user)

Sets the user identity associated with the revision.

Parameters
UserIdentity$user

Definition at line 267 of file MutableRevisionRecord.php.

References $user.

Referenced by Revision\RevisionStore\initializeMutableRevisionFromArray().

◆ setVisibility()

Revision\MutableRevisionRecord::setVisibility (   $visibility)
Parameters
int$visibility

Definition at line 221 of file MutableRevisionRecord.php.

Referenced by Revision\RevisionStore\initializeMutableRevisionFromArray().


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