From ec5ed83512ccd58f2713fc7a85fa81aa69d8fd65 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 15 Jan 2009 02:39:27 +0000 Subject: [PATCH] MINOR If the error-404.html or error-500.html file can't be opened, supress the warning so an error isn't shown in the CMS git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@70188 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/ErrorPage.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/model/ErrorPage.php b/core/model/ErrorPage.php index 41eb8ee4b..010d806ea 100755 --- a/core/model/ErrorPage.php +++ b/core/model/ErrorPage.php @@ -100,11 +100,17 @@ class ErrorPage extends Page { $response = Director::test(Director::makeRelative($this->Link())); $errorContent = $response->getBody(); + // Check we have an assets base directory, creating if it we don't if(!file_exists(ASSETS_PATH)) { mkdir(ASSETS_PATH, 02775); } - if($fh = fopen(ASSETS_PATH . "/error-$this->ErrorCode.html", "w")) { + // Path to the error file in the file store + $errorFile = ASSETS_PATH . "/error-$this->ErrorCode.html"; + + // Attempt to open the file, writing it if it doesn't exist + $fh = @fopen($errorFile, "w"); + if($fh) { fwrite($fh, $errorContent); fclose($fh); }