BUGFIX Consistently returning a record from VirtualPage->CopyContentFrom(), even if pointing to a non-existant ID (AIR-77)

This commit is contained in:
Ingo Schommer 2011-09-27 14:17:40 +02:00
parent 5d235fa9f7
commit 21d10ad32f

View File

@ -65,6 +65,9 @@ class VirtualPage extends Page {
return $virtualFields; return $virtualFields;
} }
/**
* @return SiteTree Returns the linked page, or failing that, a new object.
*/
function CopyContentFrom() { function CopyContentFrom() {
if(empty($this->record['CopyContentFromID'])) return new SiteTree(); if(empty($this->record['CopyContentFromID'])) return new SiteTree();
@ -83,7 +86,7 @@ class VirtualPage extends Page {
} }
} }
return $this->components['CopyContentFrom']; return $this->components['CopyContentFrom'] ? $this->components['CopyContentFrom'] : new SiteTree();
} }
function setCopyContentFromID($val) { function setCopyContentFromID($val) {
if(DataObject::get_by_id('SiteTree', $val) instanceof VirtualPage) $val = 0; if(DataObject::get_by_id('SiteTree', $val) instanceof VirtualPage) $val = 0;