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.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

bradjones1 created an issue. See original summary.

bradjones1’s picture

Issue summary: View changes
bradjones1’s picture

bradjones1’s picture

Issue summary: View changes
bradjones1’s picture

Updated 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_id service, not the replacement service which would match the overridden service e.g. in a database module. So this is why the issue is unique to backend_overridable, but not other tagged services like service collectors.

bradjones1’s picture

Title: Lazy services (backed by proxy classes) lose their tags, e.g. `backend_overridable` » Lazy services (backed by proxy classes) can't be `backend_overridable` because the proxy service isn't tagged

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.