fix: [feeds:saveFreetext] Soft-delete Attributes when performing a

delta-merge
pull/5973/head
mokaddem 2020-06-03 16:17:16 +02:00
parent 41506cc7e7
commit d022b0fca2
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 10 additions and 2 deletions

View File

@ -996,8 +996,16 @@ class Feed extends AppModel
}
}
if ($feed['Feed']['delta_merge'] && !empty($existsAttributesValueToId)) {
$to_delete = array_values($existsAttributesValueToId);
$this->Event->Attribute->deleteAll(array('Attribute.id' => $to_delete, 'Attribute.deleted' => 0));
$attributesToDelete = $this->Event->Attribute->find('all', array(
'conditions' => array(
'Attribute.id' => array_values($existsAttributesValueToId)
),
'recursive' => -1
));
foreach ($attributesToDelete as $k => $attribute) {
$attributesToDelete[$k]['Attribute']['deleted'] = 1;
}
$this->Event->Attribute->saveMany($attributesToDelete); // We need to trigger callback methods
}
}
if (empty($data)) {