diff --git a/core/lib/Drupal/Component/PhpStorage/FileStorage.php b/core/lib/Drupal/Component/PhpStorage/FileStorage.php index b4d35b9..7eb64b6 100644 --- a/core/lib/Drupal/Component/PhpStorage/FileStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/FileStorage.php @@ -53,14 +53,15 @@ public function load($name) { */ public function save($name, $code) { $path = $this->getFullPath($name); + $flags = parse_url($path, PHP_URL_SCHEME) == 'file' ? LOCK_EX : 0; $directory = dirname($path); if ($this->ensureDirectory($directory)) { $htaccess_path = $directory . '/.htaccess'; - if (!file_exists($htaccess_path) && file_put_contents($htaccess_path, static::htaccessLines(), LOCK_EX)) { + if (!file_exists($htaccess_path) && file_put_contents($htaccess_path, static::htaccessLines(), $flags)) { @chmod($htaccess_path, 0444); } } - return (bool) file_put_contents($path, $code, LOCK_EX); + return (bool) file_put_contents($path, $code, $flags); } /** @@ -131,9 +132,10 @@ public static function htaccessLines($private = TRUE) { * TRUE if the directory exists or has been created, FALSE otherwise. */ protected function ensureDirectory($directory, $mode = 0777) { + $flags = parse_url($directory, PHP_URL_SCHEME) == 'file' ? LOCK_EX : 0; if ($this->createDirectory($directory, $mode)) { $htaccess_path = $directory . '/.htaccess'; - if (!file_exists($htaccess_path) && file_put_contents($htaccess_path, static::htaccessLines(), LOCK_EX)) { + if (!file_exists($htaccess_path) && file_put_contents($htaccess_path, static::htaccessLines(), $flags)) { @chmod($htaccess_path, 0444); } }