mirror of https://github.com/MISP/MISP
chg: [internal] Faster editing attributes when change is required
parent
d582893bdf
commit
3ae8a09814
|
@ -3699,8 +3699,9 @@ class Attribute extends AppModel
|
|||
return $attribute;
|
||||
}
|
||||
|
||||
public function editAttribute($attribute, $eventId, $user, $objectId, $log = false, $force = false, &$nothingToChange = false)
|
||||
public function editAttribute($attribute, array $event, $user, $objectId, $log = false, $force = false, &$nothingToChange = false)
|
||||
{
|
||||
$eventId = $event['Event']['id'];
|
||||
$attribute['event_id'] = $eventId;
|
||||
$attribute['object_id'] = $objectId;
|
||||
if (isset($attribute['encrypt'])) {
|
||||
|
@ -3777,7 +3778,7 @@ class Attribute extends AppModel
|
|||
$fieldList[] = 'object_id';
|
||||
$fieldList[] = 'object_relation';
|
||||
}
|
||||
if (!$this->save($attribute, array('fieldList' => $fieldList))) {
|
||||
if (!$this->save($attribute, ['fieldList' => $fieldList, 'parentEvent' => $event])) {
|
||||
$attribute_short = (isset($attribute['category']) ? $attribute['category'] : 'N/A') . '/' . (isset($attribute['type']) ? $attribute['type'] : 'N/A') . ' ' . (isset($attribute['value']) ? $attribute['value'] : 'N/A');
|
||||
$this->loadLog()->createLogEntry($user, 'edit', 'Attribute', 0,
|
||||
'Attribute dropped due to validation for Event ' . $eventId . ' failed: ' . $attribute_short,
|
||||
|
|
|
@ -4066,7 +4066,7 @@ class Event extends AppModel
|
|||
$data['Event']['Attribute'] = array_values($data['Event']['Attribute']);
|
||||
foreach ($data['Event']['Attribute'] as $attribute) {
|
||||
$nothingToChange = false;
|
||||
$result = $this->Attribute->editAttribute($attribute, $this->id, $user, 0, false, $force, $nothingToChange);
|
||||
$result = $this->Attribute->editAttribute($attribute, $saveResult, $user, 0, false, $force, $nothingToChange);
|
||||
if ($result !== true) {
|
||||
$validationErrors['Attribute'][] = $result;
|
||||
}
|
||||
|
@ -4079,7 +4079,7 @@ class Event extends AppModel
|
|||
$data['Event']['Object'] = array_values($data['Event']['Object']);
|
||||
foreach ($data['Event']['Object'] as $object) {
|
||||
$nothingToChange = false;
|
||||
$result = $this->Object->editObject($object, $this->id, $user, false, $force, $nothingToChange);
|
||||
$result = $this->Object->editObject($object, $saveResult, $user, false, $force, $nothingToChange);
|
||||
if ($result !== true) {
|
||||
$validationErrors['Object'][] = $result;
|
||||
}
|
||||
|
|
|
@ -1021,8 +1021,9 @@ class MispObject extends AppModel
|
|||
return 'fail';
|
||||
}
|
||||
|
||||
public function editObject($object, $eventId, $user, $log, $force = false, &$nothingToChange = false)
|
||||
public function editObject($object, array $event, $user, $log, $force = false, &$nothingToChange = false)
|
||||
{
|
||||
$eventId = $event['Event']['id'];
|
||||
$object['event_id'] = $eventId;
|
||||
if (isset($object['distribution']) && $object['distribution'] == 4) {
|
||||
if (!empty($object['SharingGroup'])) {
|
||||
|
@ -1098,7 +1099,7 @@ class MispObject extends AppModel
|
|||
}
|
||||
if (!empty($object['Attribute'])) {
|
||||
foreach ($object['Attribute'] as $attribute) {
|
||||
$result = $this->Attribute->editAttribute($attribute, $eventId, $user, $object['id'], false, $force);
|
||||
$result = $this->Attribute->editAttribute($attribute, $event, $user, $object['id'], false, $force);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue