Quellcode durchsuchen

Add workaround for php bug 64634 in copy

Jordi Boggiano vor 12 Jahren
Ursprung
Commit
566313834a
2 geänderte Dateien mit 19 neuen und 1 gelöschten Zeilen
  1. 9 1
      src/Composer/Autoload/AutoloadGenerator.php
  2. 10 0
      src/Composer/IO/ConsoleIO.php

+ 9 - 1
src/Composer/Autoload/AutoloadGenerator.php

@@ -186,7 +186,15 @@ EOF;
         }
         }
         file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
         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));
         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);
         $this->eventDispatcher->dispatch(ScriptEvents::POST_AUTOLOAD_DUMP);
     }
     }

+ 10 - 0
src/Composer/IO/ConsoleIO.php

@@ -177,6 +177,16 @@ class ConsoleIO implements IOInterface
             // handle code running from a phar
             // handle code running from a phar
             if ('phar:' === substr(__FILE__, 0, 5)) {
             if ('phar:' === substr(__FILE__, 0, 5)) {
                 $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
                 $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);
                 copy($exe, $tmpExe);
                 $exe = $tmpExe;
                 $exe = $tmpExe;
             }
             }