Problem/Motivation
It looks like we broke a fair number of contributed modules by introducing the \Drupal\Core\Form\ConfigFormBase::$typedConfigManager property in #3364506: Add optional validation constraint support to ConfigFormBase because some contributed modules already have this property in their config forms but without the typehint. However, it looks like some modules have it without the typehint and some with.
Proposed resolution
Should we try changing the property name to something that is less likely to conflict with the base class? We could also trigger deprecation if <code>\Drupal\Core\Form\ConfigFormBase::$typedConfigManager exists so that contrib knows to remove the duplicate properties.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 3394197-nr-bot.txt | 1.2 KB | needs-review-queue-bot |
| #3 | 3394197-3.txt | 2.55 KB | lauriii |
Issue fork drupal-3394197
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3394197-the-new-property
changes, plain diff MR !5547
Comments
Comment #2
wim leersThat search yielded mostly false positives. Also restricting to
*Form.phpproduces far fewer: 49 instead of 588.Actually, even that produces a lot of false positives.
If we also require
ConfigFormBaseto be present, then it drops to 15 matches.That … makes it a bit more unclear.
I propose:
Comment #3
lauriiiThat seems a bit less concerning 👍 Updated the smallest list to the issue summary.
Could we mark the new property private and deprecate warning if there's existing property that is not the right type? Something along the lines of this.
Comment #4
wim leersI think that is a net improvement! 👍
Comment #5
moshe weitzman commentedDevel also broke with this change and it is not listed in your report so not sure the report is super accurate - https://gitlab.com/drupalspoons/devel/-/issues/483. Devel code is also on git.drupal.org so it is eligible.
Comment #6
lauriiiI cleaned up the proposed change from #3 and pushed it to a MR.
Comment #8
smustgrave commentedMarking so it can still make 10.2 window, and if it breaks contrib modules.
But should a follow up be opened for test coverage?
Comment #9
wim leers@smustgrave How could we test this?
@lauriii What about the concern in #2.3?
Comment #10
lauriii@Wim Leers I changed the property to a private property to try to address that. It's not perfect because you need to override the
__constructif you want to use it. Not sure if there is a perfect solution for this other than trying to fix all of contrib.You could install one of the contributed modules to see if there's a fatal error. I used Layout Paragraphs myself.
Comment #11
wim leers1.
develAFAICT Devel's form is just incorrect:
— https://3v4l.org/m6AJL
Comment #12
longwaveSo in 10.1, subclasses of ConfigFormBase did not strictly require the parent constructor to be called, because there is a helper getter for the config factory in FormBase:
Wonder if we should add a similar helper for the typed config manager service?
Also makes me wonder if forms should use setter injection for base dependencies (config factory, typed config manager, anything new we want to add in the future) and constructor injection for specific dependencies for individual forms?
Comment #13
wim leersI like that proposal, @longwave. It's pragmatic, fixes the current disruption in
10.2.0-beta1and prevents future disruption.Marking to get +1 from either (and hopefully both) @catch and @lauriii.
Comment #14
catchYeah that sounds worth doing to me.
Comment #15
longwaveAs this is a regression for contrib we should try to resolve it before 10.2.0-rc1 (this week) if possible.
Comment #16
phenaproximaAdded the helpful getter method, and changed the constructor deprecation so that it allows anything, but issues a deprecation if you pass in something that isn't
TypedConfigManagerInterface.Comment #17
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #18
wim leersNo remarks.
Comment #19
longwaveThis should solve the problem for contrib and we can clean it up further in 11.x. Getting this in now so we fix the regression in 10.2.0-rc1.
Committed and pushed a9865eb372 to 11.x and 1142669363 to 10.2.x. Thanks!
Will also update and publish the change record.
Comment #22
wim leersCR updated 👍
Comment #23
moshe weitzman commentedThanks for the fix.
FYI I just changed Devel's create() method so it avoids this sort of problem and avoids a PHPStan complaint as well - https://gitlab.com/drupalspoons/devel/-/merge_requests/164.
Comment #24
wim leers👍