From df0d813a0628292de92af73b056aa77176c3cb70 Mon Sep 17 00:00:00 2001 From: THofman Date: Tue, 23 Dec 2014 11:44:06 +0100 Subject: [PATCH] The results of is_dir() are cached So before calling is_dir() for the second time, clearstatcache of the dir --- lib/Twig/Environment.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 4439a6c31..bf57589da 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -1232,8 +1232,11 @@ class Twig_Environment { $dir = dirname($file); if (!is_dir($dir)) { - if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new RuntimeException(sprintf("Unable to create the cache directory (%s).", $dir)); + if (false === @mkdir($dir, 0777, true)) { + clearstatcache(false, $dir); + if (!is_dir($dir)) { + throw new RuntimeException(sprintf("Unable to create the cache directory (%s).", $dir)); + } } } elseif (!is_writable($dir)) { throw new RuntimeException(sprintf("Unable to write in the cache directory (%s).", $dir));