[icinga-checkins] icinga.org: icingaweb2-module-director/master: GroupMembershipCache: fix messed up properties

git at icinga.org git at icinga.org
Tue Oct 11 17:27:03 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 785746fb261ace92d8fdab9ee91acfc5055a234b
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=785746fb261ace92d8fdab9ee91acfc5055a234b

Author: Thomas Gelf <thomas at gelf.net>
Date:   Tue Oct 11 15:26:31 2016 +0000

GroupMembershipCache: fix messed up properties

fixes #12887

---

 library/Director/Db/Cache/GroupMembershipCache.php |   18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/library/Director/Db/Cache/GroupMembershipCache.php b/library/Director/Db/Cache/GroupMembershipCache.php
index 2154de2..ddf7d0b 100644
--- a/library/Director/Db/Cache/GroupMembershipCache.php
+++ b/library/Director/Db/Cache/GroupMembershipCache.php
@@ -11,12 +11,10 @@ class GroupMembershipCache
 
     protected $table;
 
-    protected $groupsClass;
+    protected $groupClass;
 
     protected $memberships;
 
-    protected $membershipsById;
-
     /** @var Db Director database connection */
     protected $connection;
 
@@ -35,7 +33,7 @@ class GroupMembershipCache
     protected function loadAllMemberships()
     {
         $db = $this->connection->getDbAdapter();
-        $this->memberships = $this->membershipsById = array();
+        $this->memberships = array();
 
         $type  = $this->type;
         $table = $this->table;
@@ -58,11 +56,11 @@ class GroupMembershipCache
         )->order('g.object_name');
 
         foreach ($db->fetchAll($query) as $row) {
-            if (! array_key_exists($row->object_id, $this->membershipsById)) {
-                $this->membershipsById[$row->object_id] = array();
+            if (! array_key_exists($row->object_id, $this->memberships)) {
+                $this->memberships[$row->object_id] = array();
             }
 
-            $this->membershipsById[$row->object_id][$row->group_id] = $row->group_name;
+            $this->memberships[$row->object_id][$row->group_id] = $row->group_name;
         }
     }
 
@@ -87,10 +85,10 @@ class GroupMembershipCache
     public function getGroupsForObject(IcingaObject $object)
     {
         $groups = array();
-        $class = $this->groupsClass;
-
+        $class = $this->groupClass;
         foreach ($this->listGroupIdsForObject($object) as $id) {
-            $groups[] = $class::loadWithAutoIncId($id, $this->connection);
+            $object = $class::loadWithAutoIncId($id, $this->connection);
+            $groups[$object->object_name] = $object;
         }
 
         return $groups;



More information about the icinga-checkins mailing list