diff --git a/core/lib/Drupal/Core/Form/ConfigFormBase.php b/core/lib/Drupal/Core/Form/ConfigFormBase.php index 83194fb58d..8f24090750 100644 --- a/core/lib/Drupal/Core/Form/ConfigFormBase.php +++ b/core/lib/Drupal/Core/Form/ConfigFormBase.php @@ -50,7 +50,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { } } $text = Markup::create($text); - drupal_set_message(t("This form has values that are overridden either by a module or by settings files.
You can still change them and they will be saved in the config storage, but the changes will maybe not appear within the site.
@overrides", ['@overrides' => $text] ), "warning"); + drupal_set_message(t("This form has values that are overridden either by a module or by settings files.
You can still change them and they will be saved in the config storage, but the changes will maybe not appear within the site.
@overrides", ['@overrides' => $text]), "warning"); } $form['actions']['#type'] = 'actions'; diff --git a/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php b/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php index 0764da2fe7..ddffb3ba34 100644 --- a/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php +++ b/core/lib/Drupal/Core/Form/ConfigFormBaseTrait.php @@ -68,7 +68,6 @@ protected function config($name) { * the keys are multidimensional) and last the original string of the * config, the value is the overridden string. Example: * 'system.site' => array('page.403' => array('original' => 'overridden')) - * */ protected function getConfigOverrides() { /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */ @@ -87,16 +86,18 @@ protected function getConfigOverrides() { // Forms define which config objects they are using for editing, therefore // these are also the ones which can be overwritten. foreach ($this->getEditableConfigNames() as $name) { - // Loading the config with ->get() which means they are loaded overridden + // Loading the config with ->get() which means they are loaded overridden. $config = $config_factory->get($name); // Diff the overwritten with the original config, returns a diff with only // values that have overrides, others are removed. - - $diff_overwritten = DiffArray::diffAssocRecursive($config->get(), $config->getOriginal('', FALSE)); + if (!$config_values = $config->getOriginal('', FALSE)) { + continue; + } + $diff_overwritten = DiffArray::diffAssocRecursive($config->get(), $config_values); // We are also interested in the original strings, so we do the same on - // the oder side around. - $diff_original = DiffArray::diffAssocRecursive($config->getOriginal('', FALSE), $config->get()); + // the other side around. + $diff_original = DiffArray::diffAssocRecursive($config_values, $config->get()); // Config objects are multidimensional. Flatten them with the keys // concatenated with dots. @@ -113,38 +114,40 @@ protected function getConfigOverrides() { } /** - * Flattens an nested array. + * Flattens a nested array. * * The scheme used is: * 'key' => array('key2' => array('key3' => 'value')) * Becomes: * 'key.key2.key3' => 'value' * - * This function takes an array by reference and will modify it + * This function takes an array by reference and will modify it. * - * @param array &$messages The array that will be flattened - * @param array $subnode Current subnode being parsed, used internally for recursive calls - * @param string $path Current path being parsed, used internally for recursive calls + * @param array &$messages + * The array that will be flattened. + * @param array $subnode + * Current subnode being parsed, used internally for recursive calls. + * @param string $path + * Current path being parsed, used internally for recursive calls. */ - private function flattenArray(array &$messages, array $subnode = null, $path = null) - { - if (null === $subnode) { + private function flattenArray(array &$messages, array $subnode = NULL, $path = NULL) { + if (NULL === $subnode) { $subnode = &$messages; } foreach ($subnode as $key => $value) { if (is_array($value)) { - $nodePath = $path ? $path.'.'.$key : $key; - $this->flattenArray($messages, $value, $nodePath); - if (null === $path) { + $node_path = $path ? $path . '.' . $key : $key; + $this->flattenArray($messages, $value, $node_path); + if (NULL === $path) { unset($messages[$key]); } - } elseif (null !== $path) { - $messages[$path.'.'.$key] = $value; + } + elseif (NULL !== $path) { + $messages[$path . '.' . $key] = $value; } } } - /** * Gets the configuration names that will be editable. *