Problem/Motivation
The current order is
- Services YAML files listed in
$settings['container_yamls'] - The site specific service YAML
However, default.services.yml recommends setting twig.config and similar in the site specific service YAML. Because of this, it's not possible to override the twig.config in development.services.yml
The real problem is the blur that happened between "site specific services YAML" and "mandatory default parameters in a services YAML".
Proposed resolution
Move the site specific service YAML into $settings['container_yamls'].
Remaining tasks
User interface changes
API changes
Beta phase evaluation
| Issue category | Bug, because its clearly a error how it works at the moment |
|---|---|
| Issue priority | Major, because environment specific overrides of parameters don't work. |
| Disruption | No disruption, especially given that people actually might have relied on that it worked how its expected to work. |
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | 2381763_29.patch | 9.59 KB | chx |
| #29 | interdiff.txt | 893 bytes | chx |
Comments
Comment #1
webflo commentedComment #2
dawehnerDo we have existing tests for environment overrides? I would assume we don't have at all.
Comment #4
webflo commentedComment #5
webflo commentedComment #6
dawehnerSeems legit
Comment #7
chx commentedComment #10
chx commentedActually, I have an idea: let's remove sites/default/services.yml as a special thing and let's just add
$settings['container_yamls][] = __DIR__ . '/services.yml';intodefault.settings.phpand then everyone can order whichever way they want.Comment #11
chx commentedNote that after that adding
$settings['container_yamls][] = 'development.services.yml';to the bottom of settings.php will override thesites/default/services.ymljust fine. It's just simpler yet more flexible code.Comment #13
chx commentedLike this.
Comment #15
chx commentedComment #17
chx commentedComment #18
dawehnerThank you for updating the issue summary.
It feels better to have the normal services.yml file included in the test, even it doesn't matter technically.
Comment #19
chx commentedThere's no "normal services.yml" any more, that's sort of the point.
Comment #20
catchThis will break sites upgrading from beta to beta, so tagging. Also we should add the exception to handle that case (or other situations where a settings.php gets copied around).
Comment #21
chx commentedThere's no interdiff as the interdiff is not significantly smaller than the whole patch.
Comment #22
chx commentedCovering the new exception with a test.
Comment #24
dawehnerThank you for adding the helpful exception as well as the test.
Comment #26
chx commentedOh installer tests. How do I love thee.
Comment #27
dawehnerLooks still good. Someone could fix the "s" after "Add" on commit.
Comment #28
alexpottPlease? The exception message should just say that the container_yamls setting is missing.
Space between @param and @return and missing type on @return.
Comment #29
chx commentedComment #30
webflo commentedThe CR for this issue is #2414149
Comment #31
alexpott@webflo Thanks for adding the CR. Committed 6d05fc8 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.
Small fix to the exception message on commit.
Comment #33
joelpittetJust a word of caution we were looking at something very similar in #2363597: services.yml load order and one issue that needs note is that the ParameterBag used to collect the values from the yaml are overridden not merged! So if you need to change one twig service option you'll need to COPY ALL of the other options (except for the services's defaults) from the default.services.yml
Comment #34
chx commented@joelpittet you probably want to edit the CR. Thanks!
Comment #35
mikeker commentedI just got bit by #33. Adding the CR update tag and hoping to come back to this later today to investigate.
Considering that you can have any number of services.yml files that override each other, a setting could easily get lost and buried because it wasn't propagated to the next services.yml. Ideally, we would fix this when consuming the yamls (fetch existing options, merge new options, set merged version) as copy/pasting a bunch of settings that you don't want to change is a terrible, horrible, no good, very bad DX.
Comment #36
chx commentedWe might want to do a followup where we switch to using
foo.bar: valuein these YAMLs , ditch the Symfony YAML loader and load and merge ourselves.Comment #37
joelpittetAdded warning to CR, hopefully it's not to verbose: https://www.drupal.org/node/2414149
Comment #38
chx commentedSo the foo.bar notation is not necessary but writing a merging YAML loader IMO is. Just a suggestion.
Comment #39
joelpittetWell it's either we write a merging yaml loader or live with it as-is. Unlikely upstream will change the ParameterBag setter to be merging in Symfony. @mikeker interested in opening up a new issue to resolve this?
Comment #40
mikeker commented@joelpittet: Doubt I'll have time -- I'm heading out for two weeks of vacation! But you never know, I might find some free wifi at the airport... :)
I believe Symfony recommends loading the existing settings, adjusting the few that are changing, and then resaving to avoid the override issue. So, yeah, won't be changed upstream.
If someone could give me some pointers on how all that generated PHP stuff in
service_container/service_container_prod/*.phpis built, I can look into this when I get back. I haven't poked around in that part of core yet...Comment #41
mikeker commentedOh, and thanks for updating the CR!
Comment #43
joachim commentedThe documentation on turning on twig debugging needs to be updated with this: https://www.drupal.org/node/1906392, https://www.drupal.org/node/1903374.
Comment #44
znerol commentedFollowup: #2549591: Installer does not ensure presence of container_yamls setting, breaking sites installing from an empty settings.php