mirror of https://github.com/MISP/MISP
fix: Possible fix for a massive performance bug on older MYSQL versions when entering attributes
parent
ec65e19781
commit
531937ef29
|
@ -1454,27 +1454,24 @@ class Attribute extends AppModel {
|
||||||
if (!empty($a['value2']) && !isset($this->primaryOnlyCorrelatingTypes[$a['type']])) $correlatingValues[] = $a['value2'];
|
if (!empty($a['value2']) && !isset($this->primaryOnlyCorrelatingTypes[$a['type']])) $correlatingValues[] = $a['value2'];
|
||||||
foreach ($correlatingValues as $k => $cV) {
|
foreach ($correlatingValues as $k => $cV) {
|
||||||
$conditions = array(
|
$conditions = array(
|
||||||
'AND' => array(
|
'OR' => array(
|
||||||
'OR' => array(
|
'Attribute.value1' => $cV,
|
||||||
'Attribute.value1' => $cV,
|
'AND' => array(
|
||||||
'AND' => array(
|
'Attribute.value2' => $cV,
|
||||||
'Attribute.value2' => $cV,
|
'NOT' => array('Attribute.type' => $this->primaryOnlyCorrelatingTypes)
|
||||||
'NOT' => array('Attribute.type' => $this->primaryOnlyCorrelatingTypes)
|
)
|
||||||
)
|
|
||||||
),
|
|
||||||
'Attribute.type !=' => $this->nonCorrelatingTypes,
|
|
||||||
'Attribute.disable_correlation' => 0,
|
|
||||||
'Event.disable_correlation' => 0
|
|
||||||
),
|
),
|
||||||
|
'Attribute.disable_correlation' => 0,
|
||||||
|
'Event.disable_correlation' => 0,
|
||||||
'Attribute.deleted' => 0
|
'Attribute.deleted' => 0
|
||||||
);
|
);
|
||||||
if (!empty($extraConditions)) {
|
if (!empty($extraConditions)) {
|
||||||
$conditions['AND']['OR'][] = $extraConditions;
|
$conditions['OR'][] = $extraConditions;
|
||||||
}
|
}
|
||||||
$correlatingAttributes[$k] = $this->find('all', array(
|
$correlatingAttributes[$k] = $this->find('all', array(
|
||||||
'conditions' => $conditions,
|
'conditions' => $conditions,
|
||||||
'recursive => -1',
|
'recursive => -1',
|
||||||
'fields' => array('Attribute.event_id', 'Attribute.id', 'Attribute.distribution', 'Attribute.sharing_group_id', 'Attribute.deleted'),
|
'fields' => array('Attribute.event_id', 'Attribute.id', 'Attribute.distribution', 'Attribute.sharing_group_id', 'Attribute.deleted', 'Attribute.type'),
|
||||||
'contain' => array('Event' => array('fields' => array('Event.id', 'Event.date', 'Event.info', 'Event.org_id', 'Event.distribution', 'Event.sharing_group_id'))),
|
'contain' => array('Event' => array('fields' => array('Event.id', 'Event.date', 'Event.info', 'Event.org_id', 'Event.distribution', 'Event.sharing_group_id'))),
|
||||||
'order' => array(),
|
'order' => array(),
|
||||||
));
|
));
|
||||||
|
@ -1482,6 +1479,7 @@ class Attribute extends AppModel {
|
||||||
if ($correlatingAttribute['Attribute']['id'] == $a['id']) unset($correlatingAttributes[$k][$key]);
|
if ($correlatingAttribute['Attribute']['id'] == $a['id']) unset($correlatingAttributes[$k][$key]);
|
||||||
else if ($correlatingAttribute['Attribute']['event_id'] == $a['event_id']) unset($correlatingAttributes[$k][$key]);
|
else if ($correlatingAttribute['Attribute']['event_id'] == $a['event_id']) unset($correlatingAttributes[$k][$key]);
|
||||||
else if ($full && $correlatingAttribute['Attribute']['id'] <= $a['id']) unset($correlatingAttributes[$k][$key]);
|
else if ($full && $correlatingAttribute['Attribute']['id'] <= $a['id']) unset($correlatingAttributes[$k][$key]);
|
||||||
|
else if (in_array($correlatingAttribute['Attribute']['type'], $this->nonCorrelatingTypes)) unset($correlatingAttributes[$k][$key]);
|
||||||
else if (isset($this->primaryOnlyCorrelatingTypes[$a['type']]) && $correlatingAttribute['value1'] !== $a['value1']) unset($correlatingAttribute[$k][$key]);
|
else if (isset($this->primaryOnlyCorrelatingTypes[$a['type']]) && $correlatingAttribute['value1'] !== $a['value1']) unset($correlatingAttribute[$k][$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue