[icinga-checkins] icinga.org: icingaweb2-module-director/feature-ddo-playground: Fix missing set override for properties w/ underscore and fix the merge fn

git at icinga.org git at icinga.org
Tue Jun 21 17:26:01 CEST 2016


Module: icingaweb2-module-director
Branch: feature-ddo-playground
Commit: 020f8faa5f94300adae48276630bcb61310032fe
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=020f8faa5f94300adae48276630bcb61310032fe

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Tue Jun 21 17:24:59 2016 +0200

Fix missing set override for properties w/ underscore and fix the merge fn

---

 library/Director/Ddo/DdoObject.php |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/library/Director/Ddo/DdoObject.php b/library/Director/Ddo/DdoObject.php
index c19f802..f7431f7 100644
--- a/library/Director/Ddo/DdoObject.php
+++ b/library/Director/Ddo/DdoObject.php
@@ -10,6 +10,7 @@ if (version_compare(PHP_VERSION, '5.4.0') <= 0) {
 
 use Icinga\Module\Director\Data\Db\DbObject;
 use Icinga\Exception\ProgrammingError;
+use Icinga\Util\StringHelper;
 
 abstract class DdoObject extends DbObject
 {
@@ -27,6 +28,10 @@ abstract class DdoObject extends DbObject
             return parent::set($key, $this->normalizeTimestamp($value));
         }
 
+        $setter = 'set' . StringHelper::cname($key);
+        if (method_exists($this, $setter)) {
+            return $this->$setter($value);
+        }
         return parent::set($key, $value);
     }
 
@@ -66,8 +71,9 @@ abstract class DdoObject extends DbObject
         $this->hasBeenModified = false;
         $this->loadedFromDb = true;
 
-        $properties = array_merge($other->getProperties(), $this->getProperties());
-
-        $this->setProperties($properties);
+        // TODO(el): Evaluate why the array_diff is necessary
+        $this->setProperties(
+            array_diff($this->getProperties(), array_merge($other->getProperties(), $this->getProperties()))
+        );
     }
 }



More information about the icinga-checkins mailing list