Problem/Motivation
If you want to override a service that advertises itself as backend_overridable, but that service happens to be lazy (with lazy: true in its definition, with a proxy class generated) you can't override it, because ProxyServicesPass discards the service's tags. BackendCompilerPass therefore doesn't find it.
This would have worked when backend overrides were first introduced, however #2454287: Make a couple of services lazy made this service lazy.
Steps to reproduce
Override a lazy, backend-overridable service as I am doing over in #2347867: Race conditions with lock/cache, session storage - add a non-transactional database connection. It doesn't work.
Proposed resolution
Retain the original tags in the replaced definition. Ideally, we'd stop doing all this proxy class nonsense as part of #3228623: DX: Creating lazy services is too difficult/obscure/bespoke/brittle.
Comments
Comment #2
bradjones1Comment #3
bradjones1There's a fix for this included in this MR https://git.drupalcode.org/project/drupal/-/merge_requests/8273/diffs#25... on #2347867: Race conditions with lock/cache, session storage - add a non-transactional database connection if we might just be able to fix it there.
Comment #4
bradjones1Comment #5
bradjones1Updated this in the related MR - https://git.drupalcode.org/project/drupal/-/merge_requests/8273/diffs#25...
The issue isn't so much that the lazy services lose their tags, it's that backend_overridable in particular is sensitive to the service ID, and the tags on proxied services go with the new
'drupal.proxy_original_service.' . $service_idservice, not the replacement service which would match the overridden service e.g. in a database module. So this is why the issue is unique tobackend_overridable, but not other tagged services like service collectors.Comment #6
bradjones1