Permalink
Browse files

BUGFIX Consistently returning a record from VirtualPage->CopyContentF…

…rom(), even if pointing to a non-existant ID (AIR-77)
  • Loading branch information...
1 parent 5d235fa commit 21d10ad32fe2ad7ae265d9cfdc56da31b5daaf67 @chillu chillu committed Sep 27, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 code/model/VirtualPage.php
@@ -65,6 +65,9 @@ function getVirtualFields() {
return $virtualFields;
}
+ /**
+ * @return SiteTree Returns the linked page, or failing that, a new object.
+ */
function CopyContentFrom() {
if(empty($this->record['CopyContentFromID'])) return new SiteTree();
@@ -83,7 +86,7 @@ function CopyContentFrom() {
}
}
- return $this->components['CopyContentFrom'];
+ return $this->components['CopyContentFrom'] ? $this->components['CopyContentFrom'] : new SiteTree();
}
function setCopyContentFromID($val) {
if(DataObject::get_by_id('SiteTree', $val) instanceof VirtualPage) $val = 0;

0 comments on commit 21d10ad

Please sign in to comment.