-
Notifications
You must be signed in to change notification settings - Fork 52
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
The class_alias in bootstrap.php causes warnings when using preloading #47
Comments
What is your PHP version? |
@Chi-teck, it's PHP 7.4.8. |
Also, do you remember what kind of issues were there before PHP 7.4.2? I could use that for the documentation for the module I am working on. Thanks! :) |
I am not quite sure. I've just found this quote from @nikic
The PHP release notes contain some useful references. Try to search "preloading" on that page. |
Thanks! I'll include all that in the documentation. Please let me know if I can help here in another way. |
Fixes #47: Alias classes only if they haven't been aliased before.
Fixed in #48. Thank you. |
Thank you for merging this and also creating a release. It makes my documentation much easier. :) |
I am using a generated preloading script which looks something like this:
This script is set to
opcache.preload
setting. The script works and I see that the preload is making a difference, but there is a warning on all pages.After debugging, I realized this is because bootstrap.php is loaded by composer (it's part of composer.json's
autoload.files
option). As the warnings suggest, this is due to theclass_alias
line.After a lot of debugging and research, I conclude that the problem is that the preloading works somewhat differently for
class_alias
. In other words, this could be a PHP bug and I do some hints for this in php/php-src#3538 and symfony/symfony#29105.My theory is that while preloading correctly handles all the regular classes and functions, it cannot handle class_alias properly. Since class_alias runs both while preloading (as we are requiring the autoloader) and during the execution, it seems that the internal PHP entry for the class name persists during the runtime causing the warning.
The fix in my case was to wrap the class_alias call inside an if block with
class_exists
condition. I don't see any warnings after that. I'm going to create a PR against 1.x branch for that shortly.Footnote: This is tangentially related to #46 but I don't know if this change would help static analyzers.
The text was updated successfully, but these errors were encountered: