From 566313834af3a49cd3f6b41001f7d8549e0b9c96 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 28 Apr 2013 17:03:05 +0200 Subject: [PATCH] Add workaround for php bug 64634 in copy --- src/Composer/Autoload/AutoloadGenerator.php | 10 +++++++++- src/Composer/IO/ConsoleIO.php | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 3beb6d208..0fc657930 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -186,7 +186,15 @@ EOF; } file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix)); file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath)); - copy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php'); + + // use stream_copy_to_stream instead of copy + // to work around https://bugs.php.net/bug.php?id=64634 + $sourceLoader = fopen(__DIR__.'/ClassLoader.php', 'r'); + $targetLoader = fopen($targetDir.'/ClassLoader.php', 'w+'); + stream_copy_to_stream($sourceLoader, $targetLoader); + fclose($sourceLoader); + fclose($targetLoader); + unset($sourceLoader, $targetLoader); $this->eventDispatcher->dispatch(ScriptEvents::POST_AUTOLOAD_DUMP); } diff --git a/src/Composer/IO/ConsoleIO.php b/src/Composer/IO/ConsoleIO.php index 9926ca947..4f4844a8c 100644 --- a/src/Composer/IO/ConsoleIO.php +++ b/src/Composer/IO/ConsoleIO.php @@ -177,6 +177,16 @@ class ConsoleIO implements IOInterface // handle code running from a phar if ('phar:' === substr(__FILE__, 0, 5)) { $tmpExe = sys_get_temp_dir().'/hiddeninput.exe'; + + // use stream_copy_to_stream instead of copy + // to work around https://bugs.php.net/bug.php?id=64634 + $source = fopen(__DIR__.'\\hiddeninput.exe', 'r'); + $target = fopen($tmpExe, 'w+'); + stream_copy_to_stream($source, $target); + fclose($source); + fclose($target); + unset($source, $target); + copy($exe, $tmpExe); $exe = $tmpExe; }