Merge pull request #7830 from JakubOnderka/audit-log-undefined-index

fix: [log] Undefined index local
pull/7831/head
Jakub Onderka 2021-10-12 09:55:41 +02:00 committed by GitHub
commit d74343b7b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View File

@ -3616,7 +3616,11 @@ class Attribute extends AppModel
$at['event_id'] = $eventId;
$toSave[] = $at;
}
$this->AttributeTag->saveMany($toSave, ['validate' => true]);
if (!$this->AttributeTag->saveMany($toSave, ['validate' => true])) {
$this->log("Could not save tags when capturing attribute with ID {$this->id}.", LOG_WARNING);
} else if (!empty($this->AttributeTag->validationErrors)) {
$this->log("Could not save some tags when capturing attribute with ID {$this->id}: " . json_encode($this->AttributeTag->validationErrors), LOG_WARNING);
}
}
if (isset($attribute['Tag'])) {
if (!empty($attribute['Tag']['name'])) {

View File

@ -150,12 +150,13 @@ class AuditLogBehavior extends ModelBehavior
$modelName = $model->name === 'MispObject' ? 'Object' : $model->name;
if ($modelName === 'AttributeTag' || $modelName === 'EventTag') {
$action = $model->data[$model->alias]['local'] ? AuditLog::ACTION_TAG_LOCAL : AuditLog::ACTION_TAG;
$isLocal = isset($model->data[$model->alias]['local']) ? $model->data[$model->alias]['local'] : false;
$action = $isLocal ? AuditLog::ACTION_TAG_LOCAL : AuditLog::ACTION_TAG;
$tagInfo = $this->getTagInfo($model, $model->data[$model->alias]['tag_id']);
if ($tagInfo) {
$modelTitle = $tagInfo['tag_name'];
if ($tagInfo['is_galaxy']) {
$action = $model->data[$model->alias]['local'] ? AuditLog::ACTION_GALAXY_LOCAL : AuditLog::ACTION_GALAXY;
$action = $isLocal ? AuditLog::ACTION_GALAXY_LOCAL : AuditLog::ACTION_GALAXY;
if ($tagInfo['galaxy_cluster_name']) {
$modelTitle = $tagInfo['galaxy_cluster_name'];
}
@ -225,12 +226,13 @@ class AuditLogBehavior extends ModelBehavior
$id = $model->id;
if ($modelName === 'AttributeTag' || $modelName === 'EventTag') {
$action = $model->data[$model->alias]['local'] ? AuditLog::ACTION_REMOVE_TAG_LOCAL : AuditLog::ACTION_REMOVE_TAG;
$isLocal = isset($model->data[$model->alias]['local']) ? $model->data[$model->alias]['local'] : false;
$action = $isLocal ? AuditLog::ACTION_REMOVE_TAG_LOCAL : AuditLog::ACTION_REMOVE_TAG;
$tagInfo = $this->getTagInfo($model, $model->data[$model->alias]['tag_id']);
if ($tagInfo) {
$modelTitle = $tagInfo['tag_name'];
if ($tagInfo['is_galaxy']) {
$action = $model->data[$model->alias]['local'] ? AuditLog::ACTION_REMOVE_GALAXY_LOCAL : AuditLog::ACTION_REMOVE_GALAXY;
$action = $isLocal ? AuditLog::ACTION_REMOVE_GALAXY_LOCAL : AuditLog::ACTION_REMOVE_GALAXY;
if ($tagInfo['galaxy_cluster_name']) {
$modelTitle = $tagInfo['galaxy_cluster_name'];
}

View File

@ -3837,7 +3837,11 @@ class Event extends AppModel
$et['event_id'] = $this->id;
$toSave[] = $et;
}
$this->EventTag->saveMany($toSave, ['validate' => true]);
if (!$this->EventTag->saveMany($toSave, ['validate' => true])) {
$this->log("Could not save tags when capturing event with ID {$this->id}.", LOG_WARNING);
} else if (!empty($this->EventTag->validationErrors)) {
$this->log("Could not save some tags when capturing event with ID {$this->id}: " . json_encode($this->EventTag->validationErrors), LOG_WARNING);
}
}
$parentEvent = $this->find('first', array(
'conditions' => array('Event.id' => $this->id),