MINOR Code formatting and docs in VirtualPage (no functional changes)

This commit is contained in:
Ingo Schommer 2012-01-14 11:24:40 +01:00
parent 0e4e8034d6
commit 9101a75123

View File

@ -196,29 +196,30 @@ class VirtualPage extends Page {
* We have to change it to copy all the content from the original page first. * We have to change it to copy all the content from the original page first.
*/ */
function onBeforeWrite() { function onBeforeWrite() {
// On regular write, this will copy from published source. This happens on every publish $performCopyFrom = null;
if($this->extension_instances['Versioned']->migratingVersion
&& Versioned::current_stage() == 'Live') { // Determine if we need to copy values.
if($this->CopyContentFromID) { if(
$performCopyFrom = true; $this->extension_instances['Versioned']->migratingVersion
&& Versioned::current_stage() == 'Live'
&& $this->CopyContentFromID
) {
// On publication to live, copy from published source.
$performCopyFrom = true;
$stageSourceVersion = DB::query("SELECT \"Version\" FROM \"SiteTree\" WHERE \"ID\" = $this->CopyContentFromID")->value(); $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(); $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 // 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 // version might not exist, unless we're publishing the latest version
if($stageSourceVersion != $liveSourceVersion) { if($stageSourceVersion != $liveSourceVersion) {
$this->extension_instances['Versioned']->migratingVersion = null; $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 { } else {
// On regular write, copy from draft source. This is only executed when the source page changes.
$performCopyFrom = $this->isChanged('CopyContentFromID', 2) && $this->CopyContentFromID != 0; $performCopyFrom = $this->isChanged('CopyContentFromID', 2) && $this->CopyContentFromID != 0;
} }
// On publish, this will copy from published source
if($performCopyFrom && $this instanceof VirtualPage) { if($performCopyFrom && $this instanceof VirtualPage) {
// This flush is needed because the get_one cache doesn't respect site version :-( // This flush is needed because the get_one cache doesn't respect site version :-(
singleton('SiteTree')->flushCache(); singleton('SiteTree')->flushCache();