From b66eeefffae3a4649f38a5f951c03f856bfb7fa3 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Fri, 28 Sep 2018 12:05:46 +0200 Subject: [PATCH] fix: [eventGraph] prevents bug if object has no attributes --- app/Lib/Tools/EventGraphTool.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/Lib/Tools/EventGraphTool.php b/app/Lib/Tools/EventGraphTool.php index d2bfeef00..8407b5adf 100644 --- a/app/Lib/Tools/EventGraphTool.php +++ b/app/Lib/Tools/EventGraphTool.php @@ -110,10 +110,12 @@ // value rule - search in the object's atribute value $valueMatch = true; - foreach ($obj['Attribute'] as $attr) { - $valueMatch = $this->__satisfy_val_filtering($attr); - if (!$valueMatch) { - return false; + if (isset($obj['Attribute'])) { + foreach ($obj['Attribute'] as $attr) { + $valueMatch = $this->__satisfy_val_filtering($attr); + if (!$valueMatch) { + return false; + } } } return true; @@ -266,20 +268,24 @@ 'id' => $obj['id'], 'uuid' => $obj['uuid'], 'type' => $obj['name'], - 'Attribute' => $obj['Attribute'], 'label' => '', + 'Attribute' => [], 'node_type' => 'object', 'meta-category' => $obj['meta-category'], 'template_uuid' => $obj['template_uuid'], 'event_id' => $obj['event_id'], ); - array_push($this->__json['items'], $toPush); + if (isset($obj['Attribute'])) { + $toPush['Attribute'] = $obj['Attribute']; - // Record existing object_relation - foreach ($obj['Attribute'] as $attr) { - $this->__json['existing_object_relation'][$attr['object_relation']] = 0; // set-alike + // Record existing object_relation + foreach ($obj['Attribute'] as $attr) { + $this->__json['existing_object_relation'][$attr['object_relation']] = 0; // set-alike + } } + array_push($this->__json['items'], $toPush); + foreach ($obj['ObjectReference'] as $rel) { $toPush = array( 'id' => $rel['id'],