diff -u b/core/includes/bootstrap.inc b/core/includes/bootstrap.inc --- b/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -3545,8 +3545,8 @@ /** * Instantiates and statically caches the correct class for a PHP loader. * - * By default, this returns an instance of the Drupal\Component\PhpLoader\MTimeProtectedLoader - * class. + * By default, this returns an instance of the + * Drupal\Component\PhpLoader\MTimeProtectedLoader class. * * Classes implementing Drupal\Component\PhpLoader\PhpLoaderInterface can * register themselves both as a default implementation and for specific bins. diff -u b/core/lib/Drupal/Component/PhpLoader/MTimeProtectedLoader.php b/core/lib/Drupal/Component/PhpLoader/MTimeProtectedLoader.php --- b/core/lib/Drupal/Component/PhpLoader/MTimeProtectedLoader.php +++ b/core/lib/Drupal/Component/PhpLoader/MTimeProtectedLoader.php @@ -1,8 +1,13 @@ prefix, 0700, TRUE); chmod($this->prefix, 0700); } - if (!@file_put_contents($original_path, $data)) { + if (!$length = @file_put_contents($original_path, $data)) { return FALSE; } chmod($original_path, 0400); @@ -96,6 +101,7 @@ chmod($dir, 0100); $loop++; } + return $length; } /** @@ -109,6 +115,9 @@ /** * Removes everything in a directory, leaving it empty. + * + * @param $dir + * The dir to be emptied out. */ protected function cleanDir($dir) { chmod($dir, 0700); @@ -120,9 +129,16 @@ /** * Constructs the secret path based on the filename and the mtime. * + * This function returns a full path starting with $dir and ending in .php, + * the filename itself will be a secure hash based on $filename, the secret + * based to the constructor and $dir_mtime. + * * @param string $dir + * The directory containing the file. * @param string $filename + * The filename. * @param int $dir_mtime + * The mtime of $dir. */ protected function getPath($dir, $filename, $dir_mtime) { return $dir . '/' . hash_hmac('sha256', $filename, $this->secret . $dir_mtime) . '.php'; diff -u b/core/lib/Drupal/Component/PhpLoader/NativeLoader.php b/core/lib/Drupal/Component/PhpLoader/NativeLoader.php --- b/core/lib/Drupal/Component/PhpLoader/NativeLoader.php +++ b/core/lib/Drupal/Component/PhpLoader/NativeLoader.php @@ -1,7 +1,7 @@ prefix . '/' . $filename, $data); + $path = $this->prefix . '/' . $filename; + @mkdir(dirname($path), 0700, TRUE); + return file_put_contents($path, $data); } /** diff -u b/core/lib/Drupal/Component/PhpLoader/PhpLoaderInterface.php b/core/lib/Drupal/Component/PhpLoader/PhpLoaderInterface.php --- b/core/lib/Drupal/Component/PhpLoader/PhpLoaderInterface.php +++ b/core/lib/Drupal/Component/PhpLoader/PhpLoaderInterface.php @@ -1,10 +1,16 @@ array(