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 = '';
|
$filesCode = '';
|
||||||
foreach ($files as $fileIdentifier => $functionFile) {
|
foreach ($files as $fileIdentifier => $functionFile) {
|
||||||
$filesCode .= ' ' . $fileIdentifier . ' => '
|
$filesCode .= ' ' . var_export($fileIdentifier, true) . ' => '
|
||||||
. $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
|
. $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,14 +671,10 @@ METHOD_FOOTER;
|
||||||
|
|
||||||
function composerRequire$suffix(\$fileIdentifier, \$file)
|
function composerRequire$suffix(\$fileIdentifier, \$file)
|
||||||
{
|
{
|
||||||
if (empty(\$GLOBALS['composerRequiredFiles'])) {
|
if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
|
||||||
\$GLOBALS['composerRequiredFiles'] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty(\$GLOBALS['composerRequiredFiles'][\$fileIdentifier])) {
|
|
||||||
require \$file;
|
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;
|
$relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
|
||||||
|
|
||||||
if ($type === 'files') {
|
if ($type === 'files') {
|
||||||
$autoloads[var_export($this->getFileIdentifier($relativePath), true)]
|
$autoloads[$this->getFileIdentifier($package, $relativePath)] = $relativePath;
|
||||||
= $relativePath;
|
|
||||||
continue;
|
continue;
|
||||||
} elseif ($type === 'classmap') {
|
} elseif ($type === 'classmap') {
|
||||||
$autoloads[] = $relativePath;
|
$autoloads[] = $relativePath;
|
||||||
|
@ -768,9 +763,9 @@ FOOTER;
|
||||||
return $autoloads;
|
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);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'fc1e99cd93a6aa58e3b1565e688bcd87' => $baseDir . '/devfiles/foo.php',
|
'ca64fb7d3f21566080b945f028f30a2e' => $baseDir . '/devfiles/foo.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,9 +6,9 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'b18a3c4a24b1dc69fdd96098e5c28e01' => $vendorDir . '/a/a/test.php',
|
'358464b1e68dac136ef7d2ec6242b425' => $vendorDir . '/a/a/test.php',
|
||||||
'93797e35718fdafb825b1fe25c08a92c' => $vendorDir . '/b/b/test2.php',
|
'03c187060069af833190628645c24aca' => $vendorDir . '/b/b/test2.php',
|
||||||
'a57008eef928ced7c299bfea724d8441' => $vendorDir . '/c/c/foo/bar/test3.php',
|
'e6a1485c8598883535f318df5b64632f' => $vendorDir . '/c/c/foo/bar/test3.php',
|
||||||
'32e13a06a803ac6553a93454bcd3d2da' => $vendorDir . '/c/c/foo/bar/test4.php',
|
'c1fb30d7fed4befd8653c015f6c004f6' => $vendorDir . '/c/c/foo/bar/test4.php',
|
||||||
'504bb142db8acef729eeeb06b0aedec5' => $baseDir . '/root.php',
|
'168fcd186353db6d3200ede690c8cfa8' => $baseDir . '/root.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,5 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$baseDir . '/root.php',
|
'168fcd186353db6d3200ede690c8cfa8' => $baseDir . '/root.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'25b429360a61ca2629fdf9a4f484981c' => $baseDir . '/foo.php',
|
'8d2db77ca7611f10a41ca43619ad167f' => $baseDir . '/foo.php',
|
||||||
'524f65941cc9a0fa65ff0ec097ccde8a' => $baseDir . '/bar.php',
|
'54c6b911effcf924f7ff3e89a29f9217' => $baseDir . '/bar.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -51,13 +51,9 @@ class ComposerAutoloaderInitFilesAutoloadOrder
|
||||||
|
|
||||||
function composerRequireFilesAutoloadOrder($fileIdentifier, $file)
|
function composerRequireFilesAutoloadOrder($fileIdentifier, $file)
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$GLOBALS['composerRequiredFiles'] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
|
||||||
require $file;
|
require $file;
|
||||||
|
|
||||||
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,13 +51,9 @@ class ComposerAutoloaderInitFilesAutoload
|
||||||
|
|
||||||
function composerRequireFilesAutoload($fileIdentifier, $file)
|
function composerRequireFilesAutoload($fileIdentifier, $file)
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$GLOBALS['composerRequiredFiles'] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
|
||||||
require $file;
|
require $file;
|
||||||
|
|
||||||
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,15 +45,19 @@ class ComposerAutoloaderInitFilesAutoload
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||||
foreach ($includeFiles as $file) {
|
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||||
composerRequireFilesAutoload($file);
|
composerRequireFilesAutoload($fileIdentifier, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function composerRequireFilesAutoload($file)
|
function composerRequireFilesAutoload($fileIdentifier, $file)
|
||||||
{
|
{
|
||||||
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
require $file;
|
require $file;
|
||||||
|
|
||||||
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,13 +71,9 @@ class ComposerAutoloaderInitTargetDir
|
||||||
|
|
||||||
function composerRequireTargetDir($fileIdentifier, $file)
|
function composerRequireTargetDir($fileIdentifier, $file)
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['composerRequiredFiles'])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$GLOBALS['composerRequiredFiles'] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($GLOBALS['composerRequiredFiles'][$fileIdentifier])) {
|
|
||||||
require $file;
|
require $file;
|
||||||
|
|
||||||
$GLOBALS['composerRequiredFiles'][$fileIdentifier] = true;
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue