1
0
Fork 0

Merge pull request #4356 from alcohol/add-license-file-to-composer-vendor-dir

copy LICENSE file during autoload dumping ( refs #4288 )
pull/4357/head
Jordi Boggiano 2015-08-14 11:35:35 +01:00
commit 6c7e4a671b
1 changed files with 18 additions and 8 deletions

View File

@ -261,14 +261,8 @@ 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, (bool) $includePathFile, $targetDirLoader, (bool) $includeFilesFile, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $classMapAuthoritative)); file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFile, $targetDirLoader, (bool) $includeFilesFile, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $classMapAuthoritative));
// use stream_copy_to_stream instead of copy $this->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
// to work around https://bugs.php.net/bug.php?id=64634 $this->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
$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->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array( $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array(
'optimize' => (bool) $scanPsr0Packages, 'optimize' => (bool) $scanPsr0Packages,
@ -750,4 +744,20 @@ FOOTER;
return $sortedPackageMap; return $sortedPackageMap;
} }
/**
* Copy file using stream_copy_to_stream to work around https://bugs.php.net/bug.php?id=6463
*
* @param string $source
* @param string $target
*/
protected function safeCopy($source, $target)
{
$source = fopen($source, 'r');
$target = fopen($target, 'w+');
stream_copy_to_stream($source, $target);
fclose($source);
fclose($target);
}
} }