fix: [Event] Prevents bug if object has no attributes

While using the event quick filter, prevents accessing a non existing index
if the object has no attributes.
pull/3723/head
Sami Mokaddem 2018-09-27 16:34:16 +02:00
parent 50a0a6c16d
commit 126ee9eaf8
1 changed files with 6 additions and 4 deletions

View File

@ -1058,10 +1058,12 @@ class EventsController extends AppController
$this->loadModel('GalaxyCluster');
$cluster_names = $this->GalaxyCluster->find('list', array('fields' => array('GalaxyCluster.tag_name'), 'group' => array('GalaxyCluster.tag_name', 'GalaxyCluster.id')));
foreach ($event['Object'] as $k => $object) {
foreach ($object['Attribute'] as $k2 => $attribute) {
foreach ($attribute['AttributeTag'] as $k3 => $attributeTag) {
if (in_array($attributeTag['Tag']['name'], $cluster_names)) {
unset($event['Object'][$k]['Attribute'][$k2]['AttributeTag'][$k3]);
if (isset($object['Attribute'])) {
foreach ($object['Attribute'] as $k2 => $attribute) {
foreach ($attribute['AttributeTag'] as $k3 => $attributeTag) {
if (in_array($attributeTag['Tag']['name'], $cluster_names)) {
unset($event['Object'][$k]['Attribute'][$k2]['AttributeTag'][$k3]);
}
}
}
}