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
[EventDispatcher] EventSubscriberInterface::getSubscribedEvents() cannot be dynamic #35579
Comments
I am willing to work on it. Just need to know which behavior we want. |
Bad, very bad or fine to you isn't a description of a problem. |
Error logs are not handled by configured logger (such as Monolog's) injected to Everything else are other potential errors depending on their exact use cases. |
that's a good catch, this should be fixed! |
No problem.. I'd just advise to state clearly in doc whether |
If you use the EventDispatcher component in framework-context, event listeners are wired during container compilation. From the code side that's the expected behaviour and there is nothing to be changed. If you feel like some docs could be improved, please feel free to submit a pull request. :) Therefore, I am closing here. |
The issue with the registration of |
…ess of the PHP_SAPI (nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel] fix registering DebugHandlersListener regardless of the PHP_SAPI | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #35579 (comment) | License | MIT | Doc PR | - Commits ------- 3f995ac [HttpKernel] fix registering DebugHandlersListener regardless of the PHP_SAPI
Symfony version(s) affected: 3.3 and up.
Description
Currently,
RegisterListenersPass
callEventSubscriberInterface::getSubscribedEvents()
and map each event to a clearEventDispatcherInterface::addListener()
. It was potentially done as a performance optimization.Therefore, subscribed events cannot be dynamic in a
EventSubscriberInterface
. I cannot find reference if it is intended or not.Event subscribers in error
On Symfony 4.4:
DebugHandlersListener
usesPHP_SAPI
to choose if it should subscribe toConsoleEvents::COMMAND
.DebugHandlersListener::configure()
is therefore not called during a console command if the container was compiled by an HTTP request. Bad.Flex
checks if it is active through a static. Very bad. But I don't know Flex well enough to say if it is a problem in a normal flow.DumpListener
checks if a ConsoleEvents exists. Acceptable. Container should be recompiled if a new composer package is installed.DispatchPcntlSignalListener
andStopWorkerOnSigtermSignalListener
check if a pcntl function is available. Acceptable. If PHP extensions or environment changes, container recompilation could be developper responsability.Possible Solution
Either fully allows dynamic subscribers or fully disallows it. Both would require a documentation update and a fix to either of the issues described above.
The text was updated successfully, but these errors were encountered: