From 99c1383ef566c6442191981e29e232724cc0cda4 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 24 Oct 2011 19:32:38 -0700 Subject: [PATCH] If proxy directory doesn't exist & cannot be created via mkdir, a ProxyException is thrown --- lib/Doctrine/ORM/Proxy/ProxyException.php | 4 ++++ lib/Doctrine/ORM/Proxy/ProxyFactory.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyException.php b/lib/Doctrine/ORM/Proxy/ProxyException.php index 892dbebbb..29462780d 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyException.php +++ b/lib/Doctrine/ORM/Proxy/ProxyException.php @@ -36,6 +36,10 @@ class ProxyException extends \Doctrine\ORM\ORMException { return new self("You must configure a proxy directory. See docs for details"); } + public static function proxyDirectoryNotWritable() { + return new self("Your proxy directory must be writable."); + } + public static function proxyNamespaceRequired() { return new self("You must configure a proxy namespace. See docs for details"); } diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 6ab28be3a..9436bcb71 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -153,8 +153,8 @@ class ProxyFactory $file = str_replace($placeholders, $replacements, $file); $parentDirectory = dirname($fileName); - if (! is_dir($parentDirectory)) { - mkdir($parentDirectory, 0, true); + if (! is_dir($parentDirectory) && ! mkdir($parentDirectory, 0775, true)) { + throw ProxyException::proxyDirectoryNotWritable(); } file_put_contents($fileName, $file, LOCK_EX);