From db3332e629676b0328446c96a11f6190b6da536b Mon Sep 17 00:00:00 2001 From: Robert Curry Date: Fri, 20 Apr 2012 10:09:06 +1200 Subject: [PATCH] MINOR: Modify VirtualPage to work with lazy loading. --- code/model/VirtualPage.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/model/VirtualPage.php b/code/model/VirtualPage.php index 8cf5c0f6..ae289729 100644 --- a/code/model/VirtualPage.php +++ b/code/model/VirtualPage.php @@ -69,11 +69,12 @@ class VirtualPage extends Page { * @return SiteTree Returns the linked page, or failing that, a new object. */ function CopyContentFrom() { - if(empty($this->record['CopyContentFromID'])) return new SiteTree(); + $copyContentFromID = $this->CopyContentFromID; + if(!$copyContentFromID) return new SiteTree(); if(!isset($this->components['CopyContentFrom'])) { $this->components['CopyContentFrom'] = DataObject::get_by_id("SiteTree", - $this->record['CopyContentFromID']); + $copyContentFromID); // Don't let VirtualPages point to other VirtualPages if($this->components['CopyContentFrom'] instanceof VirtualPage) { @@ -89,7 +90,7 @@ class VirtualPage extends Page { return $this->components['CopyContentFrom'] ? $this->components['CopyContentFrom'] : new SiteTree(); } function setCopyContentFromID($val) { - if(DataObject::get_by_id('SiteTree', $val) instanceof VirtualPage) $val = 0; + if($val && DataObject::get_by_id('SiteTree', $val) instanceof VirtualPage) $val = 0; return $this->setField("CopyContentFromID", $val); }