chg: [attribute:beforeDelete] Replaced this->read by this->find

pull/8601/head
Sami Mokaddem 2022-09-20 10:19:44 +02:00
parent 63891253f9
commit 17c3f9410c
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 12 additions and 7 deletions

View File

@ -510,21 +510,26 @@ class Attribute extends AppModel
public function beforeDelete($cascade = true)
{
// delete attachments from the disk
$this->read(); // first read the attribute from the db
if ($this->typeIsAttachment($this->data['Attribute']['type'])) {
$this->loadAttachmentTool()->delete($this->data['Attribute']['event_id'], $this->data['Attribute']['id']);
$attribute = $this->find('first', [
'recursive' => -1,
'conditions' => [
'id' => $this->id,
]
]);
if ($this->typeIsAttachment($attribute['Attribute']['type'])) {
$this->loadAttachmentTool()->delete($attribute['Attribute']['event_id'], $attribute['Attribute']['id']);
}
// update correlation..
$this->Correlation->beforeSaveCorrelation($this->data['Attribute']);
if (!empty($this->data['Attribute']['id'])) {
$this->Correlation->beforeSaveCorrelation($attribute['Attribute']);
if (!empty($attribute['Attribute']['id'])) {
if ($this->pubToZmq('attribute')) {
$pubSubTool = $this->getPubSubTool();
$pubSubTool->attribute_save($this->data, 'delete');
$pubSubTool->attribute_save($attribute, 'delete');
}
$kafkaTopic = $this->kafkaTopic('attribute');
if ($kafkaTopic) {
$kafkaPubTool = $this->getKafkaPubTool();
$kafkaPubTool->publishJson($kafkaTopic, $this->data, 'delete');
$kafkaPubTool->publishJson($kafkaTopic, $attribute, 'delete');
}
}
}