diff --git a/core/lib/Drupal/Core/Field/PluginSettingsBase.php b/core/lib/Drupal/Core/Field/PluginSettingsBase.php index e69393a..05484f8 100644 --- a/core/lib/Drupal/Core/Field/PluginSettingsBase.php +++ b/core/lib/Drupal/Core/Field/PluginSettingsBase.php @@ -52,8 +52,8 @@ public function getSettings() { * {@inheritdoc} */ public function getSetting($key) { - // Merge defaults if we have no value for the key. - if (!$this->defaultSettingsMerged && !array_key_exists($key, $this->settings)) { + // Merge defaults if that has not been done before. + if (!$this->defaultSettingsMerged) { $this->mergeDefaults(); } return isset($this->settings[$key]) ? $this->settings[$key] : NULL; @@ -63,7 +63,8 @@ public function getSetting($key) { * Merges default settings values into $settings. */ protected function mergeDefaults() { - $this->settings += static::settings(); + // Use only settings defined by plugin. + $this->settings = array_intersect_key($this->settings, static::settings()) + static::settings(); $this->defaultSettingsMerged = TRUE; } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php index e189c2b..971d7cc 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php @@ -106,9 +106,9 @@ function testFormatterUI() { $edit = array($fieldname => 'foo'); $this->drupalPostAjaxForm(NULL, $edit, "field_test_plugin_settings_update"); - // Confirm that the settings are updated on the settings form. + // Confirm that the extra settings are not updated on the settings form. $this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit"); - $this->assertFieldByName($fieldname, 'foo'); + $this->assertNoFieldByName($fieldname, 'foo'); // Test the empty setting formatter. $edit = array('fields[field_test][type]' => 'field_empty_setting');