Simplify files autoload include function, and make sure files are included once per package even if exactly the same, refs #4186
parent
9710b26d3f
commit
3748c11709
|
@ -476,7 +476,7 @@ EOF;
|
|||
{
|
||||
$filesCode = '';
|
||||
foreach ($files as $fileIdentifier => $functionFile) {
|
||||
$filesCode .= ' ' . $fileIdentifier . ' => '
|
||||
$filesCode .= ' ' . var_export($fileIdentifier, true) . ' => '
|
||||
. $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
|
||||
}
|
||||
|
||||
|
@ -671,14 +671,10 @@ METHOD_FOOTER;
|
|||
|
||||
function composerRequire$suffix(\$fileIdentifier, \$file)
|
||||
{
|
||||
if (empty(\$GLOBALS['composerRequiredFiles'])) {
|
||||
\$GLOBALS['composerRequiredFiles'] = array();
|
||||
}
|
||||
|
||||
if (empty(\$GLOBALS['composerRequiredFiles'][\$fileIdentifier])) {
|
||||
if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
|
||||
require \$file;
|
||||
|
||||
\$GLOBALS['composerRequiredFiles'][\$fileIdentifier] = true;
|
||||
\$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -752,8 +748,7 @@ FOOTER;
|
|||
$relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
|
||||
|
||||
if ($type === 'files') {
|
||||
$autoloads[var_export($this->getFileIdentifier($relativePath), true)]
|
||||
= $relativePath;
|
||||
$autoloads[$this->getFileIdentifier($package, $relativePath)] = $relativePath;
|
||||
continue;
|
||||
} elseif ($type === 'classmap') {
|
||||
$autoloads[] = $relativePath;
|
||||
|
@ -768,9 +763,9 @@ FOOTER;
|
|||
return $autoloads;
|
||||
}
|
||||
|
||||
protected function getFileIdentifier($path)
|
||||
protected function getFileIdentifier(PackageInterface $package, $path)
|
||||
{
|
||||
return md5_file($path);
|
||||
return md5($package->getName() . ':' . str_replace("\r\n", "\n", file_get_contents($path)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,5 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'fc1e99cd93a6aa58e3b1565e688bcd87' => $baseDir . '/devfiles/foo.php',
|
||||
'ca64fb7d3f21566080b945f028f30a2e' => $baseDir . '/devfiles/foo.php',
|
||||
);
|
||||
|
|
|
@ -6,9 +6,9 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'b18a3c4a24b1dc69fdd96098e5c28e01' => $vendorDir . '/a/a/test.php',
|
||||
'93797e35718fdafb825b1fe25c08a92c' => $vendorDir . '/b/b/test2.php',
|
||||
'a57008eef928ced7c299bfea724d8441' => $vendorDir . '/c/c/foo/bar/test3.php',
|
||||
'32e13a06a803ac6553a93454bcd3d2da' => $vendorDir . '/c/c/foo/bar/test4.php',
|
||||
'504bb142db8acef729eeeb06b0aedec5' => $baseDir . '/root.php',
|
||||
'358464b1e68dac136ef7d2ec6242b425' => $vendorDir . '/a/a/test.php',
|
||||
'03c187060069af833190628645c24aca' => $vendorDir . '/b/b/test2.php',
|
||||
'e6a1485c8598883535f318df5b64632f' => $vendorDir . '/c/c/foo/bar/test3.php',
|
||||
'c1fb30d7fed4befd8653c015f6c004f6' => $vendorDir . '/c/c/foo/bar/test4.php',
|
||||
'168fcd186353db6d3200ede690c8cfa8' => $baseDir . '/root.php',
|
||||
);
|
||||
|
|
|
@ -6,5 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$baseDir . '/root.php',
|
||||
'168fcd186353db6d3200ede690c8cfa8' => $baseDir . '/root.php',
|
||||
);
|
||||
|
|
|
@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'25b429360a61ca2629fdf9a4f484981c' => $baseDir . '/foo.php',
|
||||
'524f65941cc9a0fa65ff0ec097ccde8a' => $baseDir . '/bar.php',
|
||||
'8d2db77ca7611f10a41ca43619ad167f' => $baseDir . '/foo.php',
|
||||
'54c6b911effcf924f7ff3e89a29f9217' => $baseDir . '/bar.php',
|
||||
);
|
||||
|
|
|
@ -51,13 +51,9 @@ class ComposerAutoloaderInitFilesAutoloadOrder
|
|||
|
||||
function composerRequireFilesAutoloadOrder($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||
$GLOBALS['composerRequiredFiles'] = array();
|
||||
}
|
||||
|
||||
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,13 +51,9 @@ class ComposerAutoloaderInitFilesAutoload
|
|||
|
||||
function composerRequireFilesAutoload($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||
$GLOBALS['composerRequiredFiles'] = array();
|
||||
}
|
||||
|
||||
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,15 +45,19 @@ class ComposerAutoloaderInitFilesAutoload
|
|||
$loader->register(true);
|
||||
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
foreach ($includeFiles as $file) {
|
||||
composerRequireFilesAutoload($file);
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequireFilesAutoload($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequireFilesAutoload($file)
|
||||
function composerRequireFilesAutoload($fileIdentifier, $file)
|
||||
{
|
||||
require $file;
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,13 +71,9 @@ class ComposerAutoloaderInitTargetDir
|
|||
|
||||
function composerRequireTargetDir($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
||||
$GLOBALS['composerRequiredFiles'] = array();
|
||||
}
|
||||
|
||||
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue