fix: [internal] massive performance boost when loading events with a lot of objects

pull/5266/head
iglocska 2019-10-04 09:40:04 +02:00
parent 651a2e1a4f
commit 5f8ff97616
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 6 additions and 13 deletions

View File

@ -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']]);
}
}
}