diff --git a/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php b/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php index 1cbac3c..28211f7 100644 --- a/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php +++ b/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php @@ -58,6 +58,11 @@ protected function config($name) { if (in_array($name, $this->getEditableConfigNames())) { // Get a mutable object from the factory. $config = $config_factory->getEditable($name); + + // Show a message if this config was overridden in settings.php. + if (isset($GLOBALS['config'][$name])) { + 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..503470e 100644 --- a/core/modules/config/src/Tests/ConfigFormOverrideTest.php +++ b/core/modules/config/src/Tests/ConfigFormOverrideTest.php @@ -23,6 +23,10 @@ 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 +43,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',