Merge "Simplify HTMLTitleTextField::validate"
[lhc/web/wiklou.git] / includes / Storage / MutableRevisionRecord.php
index a259ae0..72d6547 100644 (file)
@@ -44,26 +44,14 @@ class MutableRevisionRecord extends RevisionRecord {
         * the new revision will act as a null-revision.
         *
         * @param RevisionRecord $parent
-        * @param CommentStoreComment $comment
-        * @param UserIdentity $user
-        * @param string $timestamp
         *
         * @return MutableRevisionRecord
         */
-       public static function newFromParentRevision(
-               RevisionRecord $parent,
-               CommentStoreComment $comment,
-               UserIdentity $user,
-               $timestamp
-       ) {
+       public static function newFromParentRevision( RevisionRecord $parent ) {
                // TODO: ideally, we wouldn't need a Title here
                $title = Title::newFromLinkTarget( $parent->getPageAsLinkTarget() );
                $rev = new MutableRevisionRecord( $title, $parent->getWikiId() );
 
-               $rev->setComment( $comment );
-               $rev->setUser( $user );
-               $rev->setTimestamp( $timestamp );
-
                foreach ( $parent->getSlotRoles() as $role ) {
                        $slot = $parent->getSlot( $role, self::RAW );
                        $rev->inheritSlot( $slot );
@@ -140,8 +128,8 @@ class MutableRevisionRecord extends RevisionRecord {
         * @param SlotRecord $parentSlot
         */
        public function inheritSlot( SlotRecord $parentSlot ) {
-               $slot = SlotRecord::newInherited( $parentSlot );
-               $this->setSlot( $slot );
+               $this->mSlots->inheritSlot( $parentSlot );
+               $this->resetAggregateValues();
        }
 
        /**
@@ -180,6 +168,15 @@ class MutableRevisionRecord extends RevisionRecord {
                $this->resetAggregateValues();
        }
 
+       /**
+        * Applies the given update to the slots of this revision.
+        *
+        * @param RevisionSlotsUpdate $update
+        */
+       public function applyUpdate( RevisionSlotsUpdate $update ) {
+               $update->apply( $this->mSlots );
+       }
+
        /**
         * @param CommentStoreComment $comment
         */
@@ -317,6 +314,17 @@ class MutableRevisionRecord extends RevisionRecord {
                return $this->mSha1;
        }
 
+       /**
+        * Returns the slots defined for this revision as a MutableRevisionSlots instance,
+        * which can be modified to defined the slots for this revision.
+        *
+        * @return MutableRevisionSlots
+        */
+       public function getSlots() {
+               // Overwritten just guarantee the more narrow return type.
+               return parent::getSlots();
+       }
+
        /**
         * Invalidate cached aggregate values such as hash and size.
         */