Problem/Motivation

Follow-up for #3364506-103: Add optional validation constraint support to ConfigFormBase and [-105].

Restore the

@trigger_error('Implementing form-coupled validation logic is deprecated in drupal:10.2.0 and will trigger a PHP error from drupal:11.0.0. Implement ::copyFormValuesToConfig() instead, which will become an abstract method on ConfigFormBase. See https://www.drupal.org/node/3373502', E_USER_DEPRECATED);

Steps to reproduce

N/A

Proposed resolution

Add the deprecation once all ConfigFormBase subclasses in core have adopted config validation, by overriding \Drupal\Core\Form\ConfigFormBase::copyFormValuesToConfig().

Remaining tasks

  1. ✅ Wait for #3364506: Add optional validation constraint support to ConfigFormBase
  2. ✅ Wait for #3382510: Introduce a new #config_target Form API property to make it super simple to use validation constraints on simple config forms, and adopt it in several core config forms
  3. Wait for #3384790: Update all remaining ConfigFormBase subclasses in Drupal core to use #config_target
  4. … then do this. After #3364506 lands, start running tests with this, and the failures basically represent the TODO list for #3384790!

User interface changes

None.

API changes

ConfigFormBase subclasses will trigger deprecations.

Data model changes

None.

Release notes snippet

None.

CommentFileSizeAuthor
#2 3384782-2-do-not-test.patch1.07 KBwim leers

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Title: [PP-1] Follow-up for #3364506: stop ignoring a deprecation, instead update the 16 ConfigFormBase::__construct() overrides » [PP-1] Follow-up for #3364506: add deprecation once all simple config forms in core implement
Issue summary: View changes
StatusFileSize
new1.07 KB
wim leers’s picture

Title: [PP-1] Follow-up for #3364506: add deprecation once all simple config forms in core implement » [PP-3] Follow-up for #3364506: add deprecation once all simple config forms in core implement
Assigned: wim leers » Unassigned
wim leers’s picture

Title: [PP-3] Follow-up for #3364506: add deprecation once all simple config forms in core implement » [PP-2] Follow-up for #3364506: add deprecation once all simple config forms in core implement
Issue summary: View changes
wim leers’s picture

Title: [PP-2] Follow-up for #3364506: add deprecation once all simple config forms in core implement » [PP-1] Follow-up for #3364506: add deprecation once all simple config forms in core implement
Priority: Minor » Normal
wim leers’s picture

Issue summary: View changes
wim leers’s picture

#5 didn't explain how we could implement this deprecation in the >=10.2.x world.

Thanks to #3398891: Do not require the config in #config_target to be listed in getEditableConfigNames(), I see how we can now do that:

I propose that we make ConfigFormBase detect:

  1. when getEditableConfigNames() returns anything other than the empty array
  2. a deprecation is triggered in Drupal 11

Tricky thing here: for example \Drupal\search\SearchPageListBuilder uses not the base class, but the trait … and the trait does NOT have the #config_target functionality 🤔

AFAICT we'll need to deprecate in Drupal 11 only \Drupal\Core\Form\ConfigFormBase::getEditableConfigNames, not \Drupal\Core\Form\ConfigFormBaseTrait::getEditableConfigNames?

Tricky edge case: already (thanks to #3398891), a number of subclasses do not implement that method at all, and instead use RedundantEditableConfigNamesTrait;. That trait will become obsolete too!

Finally: is this issue now effectively a duplicate of #3400033: Deprecate \Drupal\Core\Form\ConfigFormBase::getEditableConfigNames() - use #config_target instead? Or vice versa?

borisson_’s picture

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.