mirror of https://github.com/MISP/MISP
chg: [internal] Little optimise Event::getRelatedAttributes
parent
e475b2bf7f
commit
7b47d49836
|
@ -870,19 +870,13 @@ class Event extends AppModel
|
|||
return $relatedEvents;
|
||||
}
|
||||
|
||||
public function getRelatedAttributes($user, $id = null, $sgids, $shadowAttribute = false, $scope = 'event')
|
||||
public function getRelatedAttributes($user, $id, $sgids, $shadowAttribute = false, $scope = 'event')
|
||||
{
|
||||
if ($shadowAttribute) {
|
||||
$settings = array('model' => 'ShadowAttribute', 'correlationModel' => 'ShadowAttributeCorrelation', 'parentIdField' => '1_shadow_attribute_id');
|
||||
} else {
|
||||
$settings = array('model' => 'Attribute', 'correlationModel' => 'Correlation', 'parentIdField' => '1_attribute_id');
|
||||
}
|
||||
|
||||
if ($scope === 'event' && $id == null) {
|
||||
$id = $this->data['Event']['id'];
|
||||
} elseif ($scope === 'attribute' && $id == null) {
|
||||
$id = $this->data['Attribute']['id'];
|
||||
}
|
||||
if (!isset($sgids) || empty($sgids)) {
|
||||
$sgids = array(-1);
|
||||
}
|
||||
|
@ -937,10 +931,7 @@ class Event extends AppModel
|
|||
} else {
|
||||
$conditionsCorrelation = array($settings['correlationModel'] . '.1_' . $scope . '_id' => $id);
|
||||
}
|
||||
$max_correlations = Configure::read('MISP.max_correlations_per_event');
|
||||
if (empty($max_correlations)) {
|
||||
$max_correlations = 5000;
|
||||
}
|
||||
$max_correlations = Configure::read('MISP.max_correlations_per_event') ?: 5000;
|
||||
$correlations = $this->{$settings['correlationModel']}->find('all', array(
|
||||
'fields' => ['event_id', 'attribute_id', 'value', $settings['parentIdField']],
|
||||
'conditions' => $conditionsCorrelation,
|
||||
|
|
Loading…
Reference in New Issue