chg: [cryptographic key] move capture function to a bulk delta function

pull/8213/head
iglocska 2022-03-13 17:02:50 +01:00
parent c42800718a
commit 8e96e2fd00
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 8 additions and 1 deletions

View File

@ -463,6 +463,7 @@ class Event extends AppModel
$this->logException('Delete of event file directory failed.', $e);
throw new InternalErrorException('Delete of event file directory failed. Please report to administrator.');
}
$this->CryptographicKey->deleteAll(['CryptographicKey.parent_type' => 'Event', 'CryptographicKey.parent_id' => $this->id]);
}
public function beforeValidate($options = array())
@ -3949,7 +3950,7 @@ class Event extends AppModel
// capture new keys, update existing, remove those no longer in the pushed data
if (!empty($data['Event']['CryptographicKey'])) {
$this->captureCryptographicKeyUpdate($data['Event']['CryptographicKey'], $data['Event']['id'], 'Event');
$this->CryptoGraphicKey->captureCryptographicKeyUpdate($data['Event']['CryptographicKey'], $data['Event']['id'], 'Event');
}
// zeroq: check if sightings are attached and add to event
@ -4129,6 +4130,12 @@ class Event extends AppModel
$eventLock->insertLockBackgroundJob($data['Event']['id'], $jobId);
}
$validationErrors = array();
// capture new keys, update existing, remove those no longer in the pushed data
if (!empty($data['Event']['CryptographicKey'])) {
$this->CryptoGraphicKey->captureCryptographicKeyUpdate($data['Event']['CryptographicKey'], $data['Event']['id'], 'Event');
}
if (isset($data['Event']['Attribute'])) {
$data['Event']['Attribute'] = array_values($data['Event']['Attribute']);
foreach ($data['Event']['Attribute'] as $attribute) {