diff -u b/core/lib/Drupal/Component/PhpStorage/FileStorage.php b/core/lib/Drupal/Component/PhpStorage/FileStorage.php --- b/core/lib/Drupal/Component/PhpStorage/FileStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/FileStorage.php @@ -70,11 +70,13 @@ * The directory path. * @param int $mode * The mode, permissions, the directory should have. + * @param bool $is_backwards_recursive + * Internal use only. * * @return bool * TRUE if the directory exists or has been created, FALSE otherwise. */ - protected function ensureDirectory($directory, $mode = 0777) { + protected function ensureDirectory($directory, $mode = 0777, $is_backwards_recursive = FALSE) { // If the directory exists already, there's nothing to do. if (is_dir($directory)) { return TRUE; @@ -84,17 +86,18 @@ if (is_dir($parent = dirname($directory))) { // If the parent directory exists, then the backwards recursion must end, // regardless of whether the subdirectory could be created. - if (mkdir($directory)) { + if ($status = mkdir($directory)) { // Only try to chmod() if the subdirectory could be created. - chmod($directory, $mode); + $status = chmod($directory, $mode); } - return TRUE; + return $is_backwards_recursive ? TRUE : $status; } - // If the directory does not exist and could not be created above, walk the - // requested directory path back up until an existing directory is hit, and - // from there, recursively create the sub-directories. If that recursion - // succeeds, create the final subdirectory. - return $this->ensureDirectory($parent, $mode) && mkdir($directory) && chmod($directory, $mode); + // If the parent directory and the requested directory does not exist and + // could not be created above, walk the requested directory path back up + // until an existing directory is hit, and from there, recursively create + // the sub-directories. Only if that recursion succeeds, create the final, + // originally requested subdirectory. + return $this->ensureDirectory($parent, $mode, TRUE) && mkdir($directory) && chmod($directory, $mode); } /**