From 56580a391ad8a74c61204b43909d40067955223c Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Tue, 29 Jan 2013 19:39:46 -0800
Subject: [PATCH] Issue #1889854 by tim.plunkett: Fixed Config import breaks on
 protected entity properties.

---
 .../Config/Entity/ConfigStorageController.php |  4 ++--
 .../Drupal/config/Tests/ConfigImportTest.php  |  1 +
 .../config/Tests/ConfigImportUITest.php       |  1 +
 .../config/config_test.dynamic.default.yml    |  1 +
 .../Plugin/Core/Entity/ConfigTest.php         | 21 +++++++++++++++++++
 5 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
index b2a94b07dca2..3dd0b0a11a1e 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
@@ -470,11 +470,11 @@ public function importChange($name, Config $new_config, Config $old_config) {
     $entity->original = clone $entity;
 
     foreach ($old_config->get() as $property => $value) {
-      $entity->original->$property = $value;
+      $entity->original->set($property, $value);
     }
 
     foreach ($new_config->get() as $property => $value) {
-      $entity->$property = $value;
+      $entity->set($property, $value);
     }
 
     $entity->save();
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php
index 95089f7641ff..5e625218e1a8 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php
@@ -108,6 +108,7 @@ function testNew() {
       'label' => 'New',
       'style' => '',
       'langcode' => 'und',
+      'protected_property' => '',
     );
     $staging->write($dynamic_name, $original_dynamic_data);
 
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
index dd24224d9b97..b91fd39658a6 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
@@ -60,6 +60,7 @@ function testImport() {
       'label' => 'New',
       'style' => '',
       'langcode' => 'und',
+      'protected_property' => '',
     );
     $staging->write($dynamic_name, $original_dynamic_data);
 
diff --git a/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml b/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml
index 3e50e3bbd3de..fefeed546c59 100644
--- a/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml
+++ b/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml
@@ -1,2 +1,3 @@
 id: default
 label: Default
+protected_property: Default
diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
index 52da77755291..574c10082b5c 100644
--- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
@@ -62,4 +62,25 @@ class ConfigTest extends ConfigEntityBase {
    */
   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;
+  }
+
 }
-- 
GitLab