Problem/Motivation
Symfony's dependency injection container should allow you to shorthand aliases:
services:
service1: '@service2'
This functionality is broken due to the rewrites in Drupal\Core\Component\DependencyInjection\YamlFileLoader::parseDefinitions() that add a 'provider' tag to a service definition.
Error: Cannot use string offset as an array in Drupal\Core\DependencyInjection\YamlFileLoader->parseDefinitions() (line 123 of core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php).
Proposed resolution
Verify that the service definition is an array definition, and not a shorthand alias, before attempting to add the 'provider' tag.
Remaining tasks
Patch attached to this issue.
User interface changes
N/A
API changes
N/A, however you are now able to use shorthand aliases in your container YAML's.
Data model changes
N/A
Comment | File | Size | Author |
---|---|---|---|
#15 | diff_7-15.txt | 3.15 KB | raman.b |
#15 | 2828099-15.patch | 2.46 KB | raman.b |
#7 | drupal-2828099-7-dependency-injection-file-loader.patch | 1.97 KB | Sweetchuck |
dependency-injection-file-loader.patch | 1.18 KB | Anonymous (not verified) | |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedGroovyCarrot created an issue. See original summary.
Comment #3
joelpittetTestbot failure, resetting status due to https://www.drupal.org/node/2828045
Comment #4
dawehnerWe should certainly add some test coverage, otherwise we might break things again.
Comment #7
SweetchuckComment #8
dawehnerNice bug report, things are tricky!
Shouldn't we still add the provider, even if it is this kind of alias?
Comment #9
SweetchuckIt is depend on what is the purpose of the "provider" key.
Do you want tack that who provides the alias or who provides the service definition?
The problem is that the alias definition which refers to another service is a simple key-value pair where the value is a string. So you can't attach additional information, such as the "tags".
I don't how a service definition parsed and processed and when will be an alias resolved to the referred service. So I can't help more.
Comment #13
mxr576bump :)
Comment #15
raman.b CreditAttribution: raman.b at OpenSense Labs commentedRe-roll for 9.2.x
Comment #16
mxr576The patch looks good to me, rtbc.
Comment #19
catchCommitted/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!