Merge pull request #6514 from JakubOnderka/fix-indefined-index

fix: [internal] `Undefined index: value` warning
pull/6538/head
Jakub Onderka 2020-11-02 14:29:47 +01:00 committed by GitHub
commit 88ec45549b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)
{