From 48a9a5c0ba85ff2a5ebc3f3d9449760908a201f9 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 9 Jan 2009 03:02:42 +0000 Subject: [PATCH] BUGFIX #3329: Improved speed of folder creation in files + images git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@69943 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- filesystem/Folder.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/filesystem/Folder.php b/filesystem/Folder.php index f19f677e4..436aec308 100755 --- a/filesystem/Folder.php +++ b/filesystem/Folder.php @@ -211,7 +211,7 @@ class Folder extends File { function onBeforeDelete() { - if($children = $this->AllChildren()) { + if($this->ID && ($children = $this->AllChildren())) { foreach($children as $child) { if(!$this->Filename || !$this->Name || !file_exists($this->getFullPath())) { $child->setField('Name',null); @@ -261,7 +261,7 @@ class Folder extends File { * Returns true if this folder has children */ public function hasChildren() { - return $this->myChildren() && $this->myChildren()->Count() > 0; + return $this->ID && $this->myChildren() && $this->myChildren()->Count() > 0; } /** @@ -270,7 +270,7 @@ class Folder extends File { public function autosetFilename() { parent::autosetFilename(); - if($children = $this->AllChildren()) { + if($this->ID && ($children = $this->AllChildren())) { $this->write(); foreach($children as $child) { @@ -287,7 +287,7 @@ class Folder extends File { protected function resetFilename($renamePhysicalFile = true) { parent::resetFilename($renamePhysicalFile); - if($children = $this->AllChildren()) { + if($this->ID && ($children = $this->AllChildren())) { $this->write(); foreach($children as $child) {