bug #38062 [DI] fix generating preload file when cache_dir is outside project_dir (nicolas-grekas)
This PR was merged into the 4.4 branch.
Discussion
----------
[DI] fix generating preload file when cache_dir is outside project_dir
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | no
| License | MIT
| Doc PR | -
Commits
-------
02db8e1523
[DI] fix generating preload file when cache_dir is outside project_dir
This commit is contained in:
commit
4222a72ee8
@ -309,7 +309,7 @@ EOF;
|
|||||||
$this->asFiles = false;
|
$this->asFiles = false;
|
||||||
|
|
||||||
if ($this->preload && null !== $autoloadFile = $this->getAutoloadFile()) {
|
if ($this->preload && null !== $autoloadFile = $this->getAutoloadFile()) {
|
||||||
$autoloadFile = substr($this->export($autoloadFile), 2, -1);
|
$autoloadFile = trim($this->export($autoloadFile), '()\\');
|
||||||
|
|
||||||
$code[$options['class'].'.preload.php'] = <<<EOF
|
$code[$options['class'].'.preload.php'] = <<<EOF
|
||||||
<?php
|
<?php
|
||||||
@ -2076,9 +2076,7 @@ EOF;
|
|||||||
|
|
||||||
private function getAutoloadFile(): ?string
|
private function getAutoloadFile(): ?string
|
||||||
{
|
{
|
||||||
if (null === $this->targetDirRegex) {
|
$file = null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (spl_autoload_functions() as $autoloader) {
|
foreach (spl_autoload_functions() as $autoloader) {
|
||||||
if (!\is_array($autoloader)) {
|
if (!\is_array($autoloader)) {
|
||||||
@ -2097,14 +2095,14 @@ EOF;
|
|||||||
if (0 === strpos($class, 'ComposerAutoloaderInit') && $class::getLoader() === $autoloader[0]) {
|
if (0 === strpos($class, 'ComposerAutoloaderInit') && $class::getLoader() === $autoloader[0]) {
|
||||||
$file = \dirname((new \ReflectionClass($class))->getFileName(), 2).'/autoload.php';
|
$file = \dirname((new \ReflectionClass($class))->getFileName(), 2).'/autoload.php';
|
||||||
|
|
||||||
if (preg_match($this->targetDirRegex.'A', $file)) {
|
if (null !== $this->targetDirRegex && preg_match($this->targetDirRegex.'A', $file)) {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getClasses(Definition $definition): array
|
private function getClasses(Definition $definition): array
|
||||||
|
Reference in New Issue
Block a user