mirror of https://github.com/MISP/MISP
fix: [internal] massive performance boost when loading events with a lot of objects
parent
651a2e1a4f
commit
5f8ff97616
|
@ -2159,6 +2159,8 @@ class Event extends AppModel
|
|||
}
|
||||
$event = $this->__filterBlockedAttributesByTags($event, $options, $user);
|
||||
$event['Attribute'] = $this->__attachSharingGroups(!$options['sgReferenceOnly'], $event['Attribute'], $sharingGroupData);
|
||||
// move all object attributes to a temporary container
|
||||
$tempObjectAttributeContainer = array();
|
||||
foreach ($event['Attribute'] as $key => $attribute) {
|
||||
if ($options['enforceWarninglist']) {
|
||||
if (!$this->Warninglist->filterWarninglistAttributes($warninglists, $attribute, $this->Warninglist)) {
|
||||
|
@ -2223,12 +2225,7 @@ class Event extends AppModel
|
|||
}
|
||||
}
|
||||
if (!$flatten && $event['Attribute'][$key]['object_id'] != 0) {
|
||||
foreach ($event['Object'] as $objectKey => $object) {
|
||||
if ($object['id'] == $event['Attribute'][$key]['object_id']) {
|
||||
$event['Object'][$objectKey]['Attribute'][] = $event['Attribute'][$key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$tempObjectAttributeContainer[$event['Attribute'][$key]['object_id']][] = $event['Attribute'][$key];
|
||||
unset($event['Attribute'][$key]);
|
||||
}
|
||||
}
|
||||
|
@ -2237,13 +2234,9 @@ class Event extends AppModel
|
|||
if (!empty($event['Object'])) {
|
||||
$event['Object'] = $this->__attachSharingGroups(!$options['sgReferenceOnly'], $event['Object'], $sharingGroupData);
|
||||
foreach ($event['Object'] as $objectKey => $objectValue) {
|
||||
if (!empty($event['Object'][$objectKey]['Attribute'])) {
|
||||
$event['Object'][$objectKey]['Attribute'] = $this->__attachSharingGroups(!$options['sgReferenceOnly'], $event['Object'][$objectKey]['Attribute'], $sharingGroupData);
|
||||
foreach ($event['Object'][$objectKey]['Attribute'] as $akey => $adata) {
|
||||
if ($adata['category'] === 'Financial fraud') {
|
||||
$event['Object'][$objectKey]['Attribute'][$akey] = $this->Attribute->attachValidationWarnings($adata);
|
||||
}
|
||||
}
|
||||
if (!empty($tempObjectAttributeContainer[$objectValue['id']])) {
|
||||
$event['Object'][$objectKey]['Attribute'] = $tempObjectAttributeContainer[$objectValue['id']];
|
||||
unset($tempObjectAttributeContainer[$objectValue['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue