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