Skip to content

Commit

Permalink
BUG Fix doRollbackTo() writing old / unsaved version over restored ve…
Browse files Browse the repository at this point in the history
…rsion

See warning on PHPDoc
  • Loading branch information
Damian Mooyman committed Feb 19, 2018
1 parent b702a49 commit 8be3930
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Versioned.php
Original file line number Diff line number Diff line change
Expand Up @@ -2325,7 +2325,6 @@ public function doRollbackTo($version)
$owner = $this->owner;
$owner->extend('onBeforeRollback', $version);
$owner->copyVersionToStage($version, static::DRAFT, true);
$owner->writeWithoutVersion();
$owner->extend('onAfterRollback', $version);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/php/VersionedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ public function testPublishCreateNewVersion()

public function testRollbackTo()
{
/** @var VersionedTest\AnotherSubclass $page1 */
$page1 = $this->objFromFixture(VersionedTest\AnotherSubclass::class, 'subclass1');
$page1->Content = 'orig';
$page1->write();
Expand All @@ -318,6 +319,7 @@ public function testRollbackTo()
$page1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$changedVersion = $page1->Version;

$page1->Content = 'should be discarded';
$page1->doRollbackTo($origVersion);
$page1 = Versioned::get_one_by_stage(
VersionedTest\TestObject::class,
Expand Down

0 comments on commit 8be3930

Please sign in to comment.