Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DI] fix related to preloading #33539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ private function getAutoloadFile(): ?string

foreach (get_declared_classes() as $class) {
if (0 === strpos($class, 'ComposerAutoloaderInit') && $class::getLoader() === $autoloader[0]) {
$file = (new \ReflectionClass($class))->getFileName();
$file = \dirname((new \ReflectionClass($class))->getFileName(), 2).'/autoload.php';

if (preg_match($this->targetDirRegex.'A', $file)) {
return $file;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage as BaseExpressionLanguage;

if (!class_exists(BaseExpressionLanguage::class)) {
throw new \ReflectionException(BaseExpressionLanguage::class.' not found.');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to #32995

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does that solve #32995 ? It‘s still going to be an exception thrown during autoload. Thus we should get a fatal here, if someone tries to autoload the ExpressionLanguage class defined in this file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#32995 is about the fact that PHP 7.4 does not properly allows us to turn a missing parent class into a catcheable exception.
This is throwing an exception before PHP encounters the missing parent class.

Copy link
Member Author

@nicolas-grekas nicolas-grekas Sep 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue described in #32995 happens when the parent class fails to be loaded while the engine already registered the child as "now loading". This throw happens before the child is flagged as such, thus the exception can be properly caught.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that a return; would do it too. I'm going to update.

}

/**
* Adds some function to the default ExpressionLanguage.
*
Expand Down