diff --git a/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php b/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php index 1cbac3c..8380860 100644 --- a/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php +++ b/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php @@ -58,6 +58,14 @@ protected function config($name) { if (in_array($name, $this->getEditableConfigNames())) { // Get a mutable object from the factory. $config = $config_factory->getEditable($name); + + // Compare editable and possibly overridden values and alert user if there + // are overrides that may affect this form. + $data = $config->get(); + $original_data = $config_factory->get($name)->get(); + if ($data !== $original_data) { + drupal_set_message(t("This form may include elements which have overridden values in your current context. Editing those values will save changes but will only be used if overrides don't apply."), 'warning'); + } } else { $config = $config_factory->get($name); diff --git a/core/modules/config/src/Tests/ConfigFormOverrideTest.php b/core/modules/config/src/Tests/ConfigFormOverrideTest.php index 14726c5..3d633b7 100644 --- a/core/modules/config/src/Tests/ConfigFormOverrideTest.php +++ b/core/modules/config/src/Tests/ConfigFormOverrideTest.php @@ -23,6 +23,11 @@ class ConfigFormOverrideTest extends WebTestBase { public function testFormsWithOverrides() { $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration'))); + // Ensure warning is not present if no overrides exist. + $this->drupalGet('admin/config/system/site-information'); + $this->assertNoRaw("This form may include elements which have overridden values in your current context. Editing those values will save changes but will only be used if overrides don't apply."); + + $overridden_name = 'Site name global conf override'; // Set up an override. @@ -39,6 +44,9 @@ public function testFormsWithOverrides() { $elements = $this->xpath('//input[@name="site_name"]'); $this->assertIdentical((string) $elements[0]['value'], 'Drupal'); + // Ensure the warning is displayed. + $this->assertRaw("This form may include elements which have overridden values in your current context. Editing those values will save changes but will only be used if overrides don't apply."); + // Submit the form and ensure the site name is not changed. $edit = array( 'site_name' => 'Custom site name',