Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
You can reference a service via an alias.
Usually the compiler pass takes care of that, but if you want to do it without compile() this will trigger a bug. Core itself is not affected.
Proposed resolution
- Fix it.
Comment | File | Size | Author |
---|---|---|---|
#3 | optimizedphparraydumper-2749819-2--tests.patch | 2.36 KB | Fabianx |
#3 | optimizedphparraydumper-2749819-2.patch | 3.45 KB | Fabianx |
#5 | example.txt | 2.12 KB | dawehner |
Comments
Comment #2
dawehnerNote: The same problem exists in the symfony implementation as well. They call it by design.
Comment #3
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedComment #4
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commented#2: Symfony works fine, for the use case tested here.
Comment #5
dawehnerI just ran fabian's example code against symfony master, see patch file, to prove that this kind of syntax works. Wow.
Comment #9
catchCommitted/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!
Comment #10
Wim LeersI'd swear I opened an issue for this months ago…
Comment #11
Wim LeersThis seems very closely related to #2650812: Container::has() doesn't work for service aliases (consequently, decorating services doesn't work). Reopening this to assess its relation to that issue. Then we can mark this again.
Comment #12
Wim LeersIn any case, this was a bugfix for #2497243: Replace Symfony container with a Drupal one, stored in cache.
Comment #13
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedMarking back as fixed as this is a very special case that should never happen in Core as ContainerBuilder is compile'd().
I will take a look at the other issue to assess it.
Comment #14
Wim LeersThanks!