From 21d10ad32fe2ad7ae265d9cfdc56da31b5daaf67 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 27 Sep 2011 14:17:40 +0200 Subject: [PATCH] BUGFIX Consistently returning a record from VirtualPage->CopyContentFrom(), even if pointing to a non-existant ID (AIR-77) --- code/model/VirtualPage.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/model/VirtualPage.php b/code/model/VirtualPage.php index fd9fa292..eb690f14 100644 --- a/code/model/VirtualPage.php +++ b/code/model/VirtualPage.php @@ -65,6 +65,9 @@ class VirtualPage extends Page { 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 @@ class VirtualPage extends Page { } } - 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;