mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixed SiteTree_versions version numbers for published virtual pages. (from r98675) (from r99065)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102833 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
000d892256
commit
ffd0774839
@ -149,6 +149,15 @@ class VirtualPage extends Page {
|
||||
&& Versioned::current_stage() == 'Live') {
|
||||
$performCopyFrom = true;
|
||||
|
||||
$stageSourceVersion = DB::query("SELECT Version FROM SiteTree WHERE ID = $this->CopyContentFromID")->value();
|
||||
$liveSourceVersion = DB::query("SELECT Version FROM SiteTree_Live WHERE ID = $this->CopyContentFromID")->value();
|
||||
|
||||
// We're going to create a new VP record in SiteTree_versions because the published
|
||||
// version might not exist, unless we're publishing the latest version
|
||||
if($stageSourceVersion != $liveSourceVersion) {
|
||||
$this->extension_instances['Versioned']->migratingVersion = null;
|
||||
}
|
||||
|
||||
// On regular write, this will copy from draft source. This is only executed when the source
|
||||
// page changeds
|
||||
} else {
|
||||
|
@ -214,6 +214,7 @@ class VirtualPageTest extends SapphireTest {
|
||||
$source = $this->objFromFixture('Page', 'master');
|
||||
$source->Title = "T0";
|
||||
$source->write();
|
||||
$source->doPublish();
|
||||
|
||||
// Creating a new VP to ensure that Version #s are out of alignment
|
||||
$vp = new VirtualPage();
|
||||
@ -231,6 +232,20 @@ class VirtualPageTest extends SapphireTest {
|
||||
WHERE \"RecordID\" = $vp->ID AND \"Title\" = 'T2'")->value());
|
||||
$this->assertEquals($vp->ID, DB::query("SELECT \"RecordID\" FROM \"SiteTree_versions\"
|
||||
WHERE \"RecordID\" = $vp->ID AND \"Version\" = $vp->Version")->value());
|
||||
|
||||
$vp->doPublish();
|
||||
|
||||
// Check that the published content is copied from the published page, with a legal
|
||||
// version
|
||||
$liveVersion = DB::query("SELECT Version FROM \"SiteTree_Live\" WHERE ID = $vp->ID")->value();
|
||||
|
||||
$this->assertEquals("T0", DB::query("SELECT \"Title\" FROM \"SiteTree_Live\"
|
||||
WHERE \"ID\" = $vp->ID")->value());
|
||||
|
||||
// SiteTree_Live.Version should reference a legal entry in SiteTree_versions for the
|
||||
// virtual page
|
||||
$this->assertEquals("T0", DB::query("SELECT \"Title\" FROM \"SiteTree_versions\"
|
||||
WHERE \"RecordID\" = $vp->ID AND \"Version\" = $liveVersion")->value());
|
||||
}
|
||||
|
||||
function fixVersionNumberCache($page) {
|
||||
|
Loading…
Reference in New Issue
Block a user