-
Notifications
You must be signed in to change notification settings - Fork 84
[SymfonyCache] Remove event classes from Symfony's class cache to fix #242 #243
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
Conversation
|
There could be a simpler fix for that: force loading the necessary event classes in the build method of the bundle (the classes being used by the kernel wrapper), to be sure that these classes do not get included in the compiled file, as they will already have been loaded. |
|
your own fix is very fragile:
|
|
Thanks for your hint @stof. Can you give me a small example how to force loading the necessary event classes in the build method of the bundle? |
|
Do you mean to simply add a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the class cache is relevant, this might be an expensive thing. how do other bundles that have events solve this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbu the issue of this bundle is that it has an event before reaching the AppKernel (in its AppCache). Other bundles don't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, thanks. yeah now i get it.
|
@Naitsirch just a |
|
so we need a |
|
@dbu afaik it's enough to call |
|
Closed in favor of #244 |
Symfony's class cache (cache//classes.php) compiles classes that are loaded on each request.
But when using
EventDispatchingHttpCachethere may occure errors, when using Symfony's HttpCache, because EventDispatchingHttpCache loads some classes (Symfony\Component\EventDispatcher\Event) individually via autoload and later when the HttpKernel is bootet in a subrequest and the class cache is loaded, PHP runs into a fatal error because of redeclaration of the classSymfony\Component\EventDispatcher\Event(as you can see in #242).To fix this issue I have added an compiler pass to remove the mentioned classes from the cache class map before the cache is built. This only happens if cache invalidation is used (as it only happens in that case, afaik).
If there are any objections/annotations to this PR, please let me know.