Commit 56580a39 authored by webchick's avatar webchick
Browse files

Issue #1889854 by tim.plunkett: Fixed Config import breaks on protected entity properties.

parent a1ce6942
...@@ -470,11 +470,11 @@ public function importChange($name, Config $new_config, Config $old_config) { ...@@ -470,11 +470,11 @@ public function importChange($name, Config $new_config, Config $old_config) {
$entity->original = clone $entity; $entity->original = clone $entity;
foreach ($old_config->get() as $property => $value) { foreach ($old_config->get() as $property => $value) {
$entity->original->$property = $value; $entity->original->set($property, $value);
} }
foreach ($new_config->get() as $property => $value) { foreach ($new_config->get() as $property => $value) {
$entity->$property = $value; $entity->set($property, $value);
} }
$entity->save(); $entity->save();
......
...@@ -108,6 +108,7 @@ function testNew() { ...@@ -108,6 +108,7 @@ function testNew() {
'label' => 'New', 'label' => 'New',
'style' => '', 'style' => '',
'langcode' => 'und', 'langcode' => 'und',
'protected_property' => '',
); );
$staging->write($dynamic_name, $original_dynamic_data); $staging->write($dynamic_name, $original_dynamic_data);
......
...@@ -60,6 +60,7 @@ function testImport() { ...@@ -60,6 +60,7 @@ function testImport() {
'label' => 'New', 'label' => 'New',
'style' => '', 'style' => '',
'langcode' => 'und', 'langcode' => 'und',
'protected_property' => '',
); );
$staging->write($dynamic_name, $original_dynamic_data); $staging->write($dynamic_name, $original_dynamic_data);
......
id: default id: default
label: Default label: Default
protected_property: Default
...@@ -62,4 +62,25 @@ class ConfigTest extends ConfigEntityBase { ...@@ -62,4 +62,25 @@ class ConfigTest extends ConfigEntityBase {
*/ */
public $style; public $style;
/**
* A protected property of the configuration entity.
*
* @var string
*/
protected $protected_property;
/**
* Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::getExportProperties();
*/
public function getExportProperties() {
$properties = parent::getExportProperties();
$protected_names = array(
'protected_property',
);
foreach ($protected_names as $name) {
$properties[$name] = $this->get($name);
}
return $properties;
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment