diff --git a/src/Illuminate/Filesystem/Filesystem.php b/src/Illuminate/Filesystem/Filesystem.php index 4c4af8deaae6..b57d8cd08d62 100644 --- a/src/Illuminate/Filesystem/Filesystem.php +++ b/src/Illuminate/Filesystem/Filesystem.php @@ -128,26 +128,31 @@ public function put($path, $contents, $lock = false) * * This will also replace the target file permissions. * - * @param string $path - * @param string $content - * @throws Exception + * @param string $path + * @param string $content + * @return void + * + * @throws \Exception */ public function replace($path, $content) { - // Just in case path already exists and is a symlink, we want to make sure we get the real path. + // If the path already exists and is a symlink, make sure we get the real path... clearstatcache(true, $path); + $realPath = realpath($path); + if ($realPath) { $path = $realPath; } $dirName = dirname($path); + if (! is_writable($dirName)) { - throw new Exception("Replacing $path requires it's parent directory to be writable."); + throw new Exception("Replacing [{$path}] requires that its parent directory is writable."); } - // Write out the contents to a temp file, so we then can rename the file atomically. $tempPath = tempnam($dirName, basename($path)); + file_put_contents($tempPath, $content); rename($tempPath, $path); diff --git a/src/Illuminate/Foundation/PackageManifest.php b/src/Illuminate/Foundation/PackageManifest.php index 8c263278c830..e7389c59a4f5 100644 --- a/src/Illuminate/Foundation/PackageManifest.php +++ b/src/Illuminate/Foundation/PackageManifest.php @@ -163,6 +163,9 @@ protected function packagesToIgnore() */ protected function write(array $manifest) { - $this->files->replace($this->manifestPath, 'files->replace( + $this->manifestPath, + '