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
This commit is contained in:
Sean Harvey 2009-01-15 02:39:27 +00:00 committed by Sam Minnee
parent efde576662
commit ec5ed83512

View File

@ -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);
}