27use InvalidArgumentException;
33use Wikimedia\Assert\Assert;
62 $slot = $parent->
getSlot( $role, self::RAW );
63 $rev->inheritSlot( $slot );
67 $rev->setParentId( $parent->
getId() );
88 parent::__construct(
$title, $slots, $dbDomain );
95 Assert::parameterType(
'integer', $parentId,
'$parentId' );
97 $this->mParentId = $parentId;
117 throw new InvalidArgumentException(
118 'The given slot must be an unsaved, unattached one. '
119 .
'This slot is already attached to revision ' . $slot->
getRevision() .
'. '
120 .
'Use inheritSlot() instead to preserve a slot from a previous revision.'
124 $this->mSlots->setSlot( $slot );
137 $this->mSlots->inheritSlot( $parentSlot );
155 $this->mSlots->setContent( $role,
$content );
171 $this->mSlots->removeSlot( $role );
180 $update->
apply( $this->mSlots );
187 $this->mComment = $comment;
200 Assert::parameterType(
'string', $sha1,
'$sha1' );
202 $this->mSha1 = $sha1;
215 Assert::parameterType(
'integer', $size,
'$size' );
217 $this->mSize = $size;
224 Assert::parameterType(
'integer', $visibility,
'$visibility' );
226 $this->mDeleted = $visibility;
233 Assert::parameterType(
'string', $timestamp,
'$timestamp' );
235 $this->mTimestamp = MWTimestamp::convert( TS_MW, $timestamp );
242 Assert::parameterType(
'boolean', $minorEdit,
'$minorEdit' );
244 $this->mMinorEdit = $minorEdit;
259 Assert::parameterType(
'integer', $id,
'$id' );
270 $this->mUser = $user;
277 Assert::parameterType(
'integer', $pageId,
'$pageId' );
279 if ( $this->mTitle->exists() && $pageId !== $this->mTitle->getArticleID() ) {
280 throw new InvalidArgumentException(
281 'The given Title does not belong to page ID ' . $this->mPageId
285 $this->mPageId = $pageId;
297 if ( $this->mSize ===
null ) {
298 $this->mSize = $this->mSlots->computeSize();
313 if ( $this->mSha1 ===
null ) {
314 $this->mSha1 = $this->mSlots->computeSha1();
328 return parent::getSlots();
346class_alias( MutableRevisionRecord::class,
'MediaWiki\Storage\MutableRevisionRecord' );
Library for creating and parsing MW-style timestamps.
Represents a title within MediaWiki.
Base interface for content objects.