diff --git a/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php b/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php index 172a77b..3cabd9b 100644 --- a/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php +++ b/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php @@ -55,6 +55,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 whose values are overridden using settings.php. Editing those values will save changes but will only be used if the overrides do not 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 be1e9df..e618403 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->assertNoText('This form may include elements whose values are overridden using settings.php. Editing those values will save changes but will only be used if the overrides do not 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->assertText('This form may include elements whose values are overridden using settings.php. Editing those values will save changes but will only be used if the overrides do not apply.'); + // Submit the form and ensure the site name is not changed. $edit = array( 'site_name' => 'Custom site name',