From 0b3b4b555c1c9b3a37b5322c9a68fd794b484bb8 Mon Sep 17 00:00:00 2001 From: Saophalkun Ponlu Date: Mon, 5 Oct 2009 01:55:55 +0000 Subject: [PATCH] BUGFIX: A page type with requireDefaultRecords(), for instance ErrorPage, was created everytime on the main site when dev/build-ing (with subdomain in the url) and there's no that page type in the subsite's sitetree. --- code/SiteTreeSubsites.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/SiteTreeSubsites.php b/code/SiteTreeSubsites.php index 584ced3..b37f5ab 100644 --- a/code/SiteTreeSubsites.php +++ b/code/SiteTreeSubsites.php @@ -86,7 +86,10 @@ class SiteTreeSubsites extends DataObjectDecorator { protected $nextWriteDoesntCustomise = false; function augmentBeforeWrite() { - if(!is_numeric($this->owner->ID) && !$this->owner->SubsiteID) $this->owner->SubsiteID = Subsite::currentSubsiteID(); + // if the page hasn't been written to a database table yet and no subsite has been set, then give it a subsite + if((!is_numeric($this->owner->ID) || $this->owner->ID == 0) && !$this->owner->SubsiteID) { + $this->owner->SubsiteID = Subsite::currentSubsiteID(); + } // If the content has been changed, then the page should be marked as 'custom content' if(!$this->nextWriteDoesntCustomise && $this->owner->ID && $this->owner->MasterPageID && !$this->owner->CustomContent) {