Merge pull request #7206 from tomking2/bug/sighting_crash

fix: [api] Fixes crash when a new indicator in existing event has a sighting
pull/7230/head
Andras Iklody 2021-03-18 23:04:28 +01:00 committed by GitHub
commit 90ed58d567
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -4076,10 +4076,6 @@ class Attribute extends AppModel
$attribute['distribution'] = 5;
}
}
if (isset($attribute['Sighting']) && !empty($attribute['Sighting'])) {
$this->Sighting = ClassRegistry::init('Sighting');
$this->Sighting->captureSightings($attribute['Sighting'], $attribute['id'], $eventId, $user);
}
$fieldList = $this->editableFields;
if (empty($existingAttribute)) {
$addableFieldList = array('event_id', 'type', 'uuid');
@ -4105,6 +4101,10 @@ class Attribute extends AppModel
));
return $this->validationErrors;
} else {
if (isset($attribute['Sighting']) && !empty($attribute['Sighting'])) {
$this->Sighting = ClassRegistry::init('Sighting');
$this->Sighting->captureSightings($attribute['Sighting'], $this->id, $eventId, $user);
}
if ($user['Role']['perm_tagger']) {
/*
We should uncomment the line below in the future once we have tag soft-delete