27use InvalidArgumentException;
32use Wikimedia\Assert\Assert;
59 $slot = $parent->
getSlot( $role, self::RAW );
60 $rev->inheritSlot( $slot );
64 $rev->setParentId( $parent->
getId() );
81 parent::__construct(
$title, $slots, $dbDomain );
88 Assert::parameterType(
'integer', $parentId,
'$parentId' );
90 $this->mParentId = $parentId;
110 throw new InvalidArgumentException(
111 'The given slot must be an unsaved, unattached one. '
112 .
'This slot is already attached to revision ' . $slot->
getRevision() .
'. '
113 .
'Use inheritSlot() instead to preserve a slot from a previous revision.'
117 $this->mSlots->setSlot( $slot );
131 $this->mSlots->inheritSlot( $parentSlot );
150 $this->mSlots->setContent( $role,
$content );
167 $this->mSlots->removeSlot( $role );
177 $update->
apply( $this->mSlots );
184 $this->mComment = $comment;
197 Assert::parameterType(
'string', $sha1,
'$sha1' );
199 $this->mSha1 = $sha1;
212 Assert::parameterType(
'integer', $size,
'$size' );
214 $this->mSize = $size;
221 Assert::parameterType(
'integer', $visibility,
'$visibility' );
223 $this->mDeleted = $visibility;
230 Assert::parameterType(
'string', $timestamp,
'$timestamp' );
232 $this->mTimestamp =
wfTimestamp( TS_MW, $timestamp );
239 Assert::parameterType(
'boolean', $minorEdit,
'$minorEdit' );
241 $this->mMinorEdit = $minorEdit;
256 Assert::parameterType(
'integer', $id,
'$id' );
267 $this->mUser = $user;
274 Assert::parameterType(
'integer', $pageId,
'$pageId' );
276 if ( $this->mTitle->exists() && $pageId !== $this->mTitle->getArticleID() ) {
277 throw new InvalidArgumentException(
278 'The given Title does not belong to page ID ' . $this->mPageId
282 $this->mPageId = $pageId;
294 if ( $this->mSize ===
null ) {
295 $this->mSize = $this->mSlots->computeSize();
310 if ( $this->mSha1 ===
null ) {
311 $this->mSha1 = $this->mSlots->computeSha1();
325 return parent::getSlots();
342class_alias( MutableRevisionRecord::class,
'MediaWiki\Storage\MutableRevisionRecord' );
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Represents a title within MediaWiki.
Base interface for content objects.