MediaWiki  REL1_31
MediaWiki\Storage\RevisionSlots Class Reference

Value object representing the set of slots belonging to a revision. More...

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

Public Member Functions

 __construct ( $slots)
 
 __sleep ()
 Implemented to defy serialization. More...
 
 computeSha1 ()
 Computes the combined hash of the revisions's slots. More...
 
 computeSize ()
 Computes the total nominal size of the revision's slots, in bogo-bytes. More...
 
 getContent ( $role)
 Returns the Content of the given slot. More...
 
 getSlot ( $role)
 Returns the SlotRecord of the given slot. More...
 
 getSlotRoles ()
 Returns the slot names (roles) of all slots present in this revision. More...
 
 getSlots ()
 Returns an associative array that maps role names to SlotRecords. More...
 
 hasSlot ( $role)
 Returns whether the given slot is set. More...
 

Protected Attributes

SlotRecord[] callable $slots
 

Private Member Functions

 setSlotsInternal (array $slots)
 

Detailed Description

Value object representing the set of slots belonging to a revision.

Since
1.31

Definition at line 34 of file RevisionSlots.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\RevisionSlots::__construct (   $slots)
Parameters
SlotRecord[] | callable$slotsSlotRecords, or a callback that returns such a structure.

Definition at line 43 of file RevisionSlots.php.

References MediaWiki\Storage\RevisionSlots\$slots, and MediaWiki\Storage\RevisionSlots\setSlotsInternal().

Member Function Documentation

◆ __sleep()

MediaWiki\Storage\RevisionSlots::__sleep ( )

Implemented to defy serialization.

Exceptions
LogicExceptionalways

Definition at line 71 of file RevisionSlots.php.

◆ computeSha1()

MediaWiki\Storage\RevisionSlots::computeSha1 ( )

Computes the combined hash of the revisions's slots.

Note
For backwards compatibility, the combined hash of a single slot is that slot's hash. For consistency, the combined hash of an empty set of slots is the hash of the empty string.

@warn This is potentially expensive! It may cause all slot's content to be loaded and deserialized, then re-serialized and hashed.

Returns
string

Definition at line 187 of file RevisionSlots.php.

References MediaWiki\Storage\RevisionSlots\$slots, MediaWiki\Storage\SlotRecord\base36Sha1(), MediaWiki\Storage\SlotRecord\getSha1(), and MediaWiki\Storage\RevisionSlots\getSlots().

Referenced by MediaWiki\Tests\Storage\RevisionArchiveRecordTest\testConstructorAndGetters(), and MediaWiki\Tests\Storage\RevisionStoreRecordTest\testConstructorAndGetters().

◆ computeSize()

MediaWiki\Storage\RevisionSlots::computeSize ( )

Computes the total nominal size of the revision's slots, in bogo-bytes.

@warn This is potentially expensive! It may cause all slot's content to be loaded and deserialized.

Returns
int

Definition at line 145 of file RevisionSlots.php.

References MediaWiki\Storage\SlotRecord\getSize(), and MediaWiki\Storage\RevisionSlots\getSlots().

Referenced by MediaWiki\Tests\Storage\RevisionArchiveRecordTest\testConstructorAndGetters(), and MediaWiki\Tests\Storage\RevisionStoreRecordTest\testConstructorAndGetters().

◆ getContent()

MediaWiki\Storage\RevisionSlots::getContent (   $role)

Returns the Content of the given slot.

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.

Parameters
string$roleThe role name of the desired slot
Exceptions
RevisionAccessExceptionif the slot does not exist or slot data could not be lazy-loaded.
Returns
Content

Definition at line 88 of file RevisionSlots.php.

References MediaWiki\Storage\RevisionSlots\getSlot().

◆ getSlot()

MediaWiki\Storage\RevisionSlots::getSlot (   $role)

Returns the SlotRecord of the given slot.

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

Parameters
string$roleThe role name of the desired slot
Exceptions
RevisionAccessExceptionif the slot does not exist or slot data could not be lazy-loaded.
Returns
SlotRecord

Definition at line 103 of file RevisionSlots.php.

References MediaWiki\Storage\RevisionSlots\$slots, and MediaWiki\Storage\RevisionSlots\getSlots().

Referenced by MediaWiki\Storage\RevisionSlots\getContent().

◆ getSlotRoles()

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

References MediaWiki\Storage\RevisionSlots\$slots, and MediaWiki\Storage\RevisionSlots\getSlots().

Referenced by MediaWiki\Tests\Storage\RevisionArchiveRecordTest\testConstructorAndGetters(), and MediaWiki\Tests\Storage\RevisionStoreRecordTest\testConstructorAndGetters().

◆ getSlots()

MediaWiki\Storage\RevisionSlots::getSlots ( )

Returns an associative array that maps role names to SlotRecords.

Each SlotRecord represents the content meta-data of a slot, together they define the content of a revision.

Note
This may cause the content meta-data for the revision to be lazy-loaded.
Returns
SlotRecord[] revision slot/content rows, keyed by slot role name.

Definition at line 160 of file RevisionSlots.php.

References MediaWiki\Storage\RevisionSlots\$slots, and MediaWiki\Storage\RevisionSlots\setSlotsInternal().

Referenced by MediaWiki\Storage\RevisionSlots\computeSha1(), MediaWiki\Storage\RevisionSlots\computeSize(), MediaWiki\Storage\MutableRevisionSlots\getInheritedSlots(), MediaWiki\Storage\RevisionSlots\getSlot(), MediaWiki\Storage\RevisionSlots\getSlotRoles(), MediaWiki\Storage\MutableRevisionSlots\getTouchedSlots(), MediaWiki\Storage\RevisionSlots\hasSlot(), MediaWiki\Storage\MutableRevisionSlots\removeSlot(), and MediaWiki\Storage\MutableRevisionSlots\setSlot().

◆ hasSlot()

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

Returns whether the given slot is set.

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

Definition at line 120 of file RevisionSlots.php.

References MediaWiki\Storage\RevisionSlots\$slots, and MediaWiki\Storage\RevisionSlots\getSlots().

◆ setSlotsInternal()

MediaWiki\Storage\RevisionSlots::setSlotsInternal ( array  $slots)
private

Member Data Documentation

◆ $slots


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