Problem/Motivation

Corollary to #2239065: Overridden config bleeding through to configuration forms, but not as easy to fix.

The loading of the config entity happens in \Drupal\Core\ParamConverter\EntityConverter.
This currently applies overrides, so going to an entity form and hitting save will change your stored config.

Proposed resolution

LocaleAdminPathConfigEntityConverter currently handles this but only for language overrides. We want this for ALL overrides, move it to \Drupal\Core

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Status: Active » Needs review
FileSize
5.55 KB
10.82 KB

The test here should be good, my attempted fix is a bit questionable...

I had to update a couple things in ConfigTest to get everything to work.

The last submitted patch, 1: config-2251915-1-FAIL.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

There is in fact LocaleAdminPathConfigEntityConverter, which is supposed to solve this but:

- language overrides have since been moved to the language module instead of locale, so this is misplaced
- other kinds of overrides still apply if you don't have language/locale modules enabled we'd still need a generic solution

So I agree a generic solution is needed, but that should remove / adapt the converter already in core instead of adding yet one more way :)

tim.plunkett’s picture

I was taking a very similar approach, but it didn't occur to me that we could just adjust the configFactory directly, duh!

LocaleAdminPathConfigEntityConverter is exactly what we need, we just need it to run always, and at the right time (after other route subscribers like the AdminRouteSubscriber).

The interdiff is against the test only patch, it passes with no other tweaks.

This seems a little heavy handed, but until #1934152: FormBase::config() and ConfigFormBase::config() work entirely differently, may result in unexpected side effects is decided, this matches our expectations perfectly.

dawehner’s picture

+++ b/core/core.services.yml
@@ -411,6 +411,11 @@ services:
+    tags:
+      - { name: paramconverter, priority: 5 }

It would be great to document why we need a higher priority.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
9.74 KB
533 bytes

I copied that priority from the existing definition, and there are detailed docs on the class itself.
But I added a one-liner that should help.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Great, thank you!

tim.plunkett’s picture

Title: Overridden config bleeds through to config entity forms » Overridden config bleeds through to the admin UI, including forms

#2136559: Config entity admin lists show configuration with overrides (eg. localized) was the original issue I was looking for, marking as a dupe.
And for future reference, #2099541: ConfigEntities should not load the Entity translated on Edit Forms is where this code was added originally.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs review

Wait a minute, this does indeed solve this in a more general way now for admin forms, but not for admin listings. If @tim.plunkett was to mark #2136559: Config entity admin lists show configuration with overrides (eg. localized) as a duplicate, then this needs to solve the listings too, no?

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

I misunderstood that other issue. I reopened it, it is a very different problem-space.
Thanks @Gábor Hojtsy!

Gábor Hojtsy’s picture

Title: Overridden config bleeds through to the admin UI, including forms » Overridden config bleeds through to admin forms

Right, that is about entity *listings* on the admin interface. Titling this back to the simpler case it is then :) I think it means then that #2136559: Config entity admin lists show configuration with overrides (eg. localized) is also critical.

catch’s picture

Assigned: tim.plunkett » alexpott

Making sure Alex gets a chance to look at this before it goes in.

alexpott’s picture

Assigned: alexpott » Unassigned
Status: Reviewed & tested by the community » Needs work

Looks good a couple of minor nits.

  1. +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityFormOverrideTest.php
    @@ -0,0 +1,71 @@
    +/**
    + * Tests that config overrides do not bleed through in entity forms.
    + */
    ...
    +      'description' => 'Tests that config overrides do not bleed through in entity forms.',
    

    bleed through? How about "Test that config overrides do not (appear on|effect) entity forms."

  2. +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityFormOverrideTest.php
    @@ -0,0 +1,71 @@
    +    // Test that everything on the form is the same, but that the override
    +    // worked for the actual site name.
    

    site name?

tim.plunkett’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
9.57 KB
1.7 KB

Fixed, thanks.
I also cleaned up other parts of the test that were shamelessly copy/pasted from the other issue.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4ad6fc9 and pushed to 8.x. Thanks!

diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestController.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestController.php
index c561366..fa7618c 100644
--- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestController.php
+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestController.php
@@ -21,10 +21,10 @@ class ConfigTestController extends ControllerBase {
    * Route title callback.
    *
    * @param \Drupal\config_test\Entity\ConfigTest $config_test
-   *   The ConfigTest object to edit.
+   *   The ConfigTest object.
    *
-   * @return array
-   *   A form array as expected by drupal_render().
+   * @return string
+   *   The title for the ConfigTest edit form.
    */
   public function editTitle(ConfigTest $config_test) {
     return $this->t('Edit %label', array('%label' => $config_test->label()));

Fixed up function docblock

  • Commit 4ad6fc9 on 8.x by alexpott:
    Issue #2251915 by tim.plunkett: Overridden config bleeds through to...
Gábor Hojtsy’s picture

Issue tags: +D8MI, +language-config

Yay, its great to see again a more generalised solution for what we made up for languages only :) Tagging with D8MI too.

Gábor Hojtsy’s picture

Title: Overridden config bleeds through to admin forms » Overridden config entity bleeds through to admin forms

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.