fix: [internal] `Undefined index: value` warning

pull/6514/head
Jakub Onderka 2020-10-29 09:02:50 +01:00
parent 3c8b9c0fe4
commit bc9be1f5c9
2 changed files with 7 additions and 3 deletions

View File

@ -234,11 +234,13 @@ class ObjectsController extends AppController
$object['Attribute'][$k]['event_id'] = $eventId;
$this->MispObject->Event->Attribute->set($object['Attribute'][$k]);
if (!$this->MispObject->Event->Attribute->validates()) {
if ($this->MispObject->Event->Attribute->validationErrors['value'][0] !== 'Composite type found but the value not in the composite (value1|value2) format.') {
$validationErrors = $this->MispObject->Event->Attribute->validationErrors;
$isCompositeError = isset($validationErrors['value']) && $validationErrors['value'][0] === 'Composite type found but the value not in the composite (value1|value2) format.';
if (!$isCompositeError) {
$error = sprintf(
'Could not save object as at least one attribute has failed validation (%s). %s',
isset($attribute['object_relation']) ? $attribute['object_relation'] : 'No object_relation',
json_encode($this->MispObject->Event->Attribute->validationErrors)
json_encode($validationErrors)
);
}
}

View File

@ -643,8 +643,10 @@ class MispObject extends AppModel
return $template;
}
/*
/**
* Clean the attribute list up from artifacts introduced by the object form
* @param array $attributes
* @return string|array
*/
public function attributeCleanup($attributes)
{