[DependencyInjection] Add the "kernel.close" tag to close services on kernel shutdown - #65989
[DependencyInjection] Add the "kernel.close" tag to close services on kernel shutdown#65989Amoifr wants to merge 1 commit into
Conversation
337c74a to
77e7d16
Compare
|
Rebased on 8.2, resolving conflicts in the DependencyInjection changelog and in Fixed Also shortened the changelog entry to one line. |
|
Thanks for the rebase and for fixing that test. The three reds all look unrelated to this PR. |
77e7d16 to
7057bf3
Compare
As described in #65947, the kernel can reset services between requests but has no way to release the resources a service holds when it shuts down: bundles override
Bundle::shutdown()and make a coordinating service public to do it.This adds a
kernel.closetag, mirroringkernel.reset:AbstractKernel::shutdown()closes the tagged services once the bundles are shut down, soreboot()andKernelTestCase::ensureKernelShutdown()release them too.IGNORE_ON_UNINITIALIZED_REFERENCE: one that was never used is not instantiated just to be closed.methoddefaults toclose, andon_invalid: ignoreworks as it does forkernel.reset.services_closerreusesServicesResetter, which already skips uninitialized lazy objects and keeps closing the other services when one throws. The container is cleared even then.I went with
kernel.closerather thankernel.shutdownbecause it names the action, askernel.resetdoes. Happy to rename it, or to give the closer its own class if reusing the resetter reads oddly.