2
0
forked from Wavyzz/dolibarr

Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur
2023-10-01 16:06:58 +02:00
13 changed files with 63 additions and 28 deletions

View File

@@ -1217,22 +1217,34 @@ abstract class CommonObject
// phpcs:enable
global $user;
$error = 0;
$this->db->begin();
$sql = "DELETE FROM ".$this->db->prefix()."element_contact";
$sql .= " WHERE rowid = ".((int) $rowid);
dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG);
if ($this->db->query($sql)) {
if (!$notrigger) {
$result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user);
if ($result < 0) {
$this->db->rollback();
return -1;
}
if (!$error && empty($notrigger)) {
// Call trigger
$this->context['contact_id'] = ((int) $rowid);
$result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error) {
dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql .= " WHERE rowid = ".((int) $rowid);
$result = $this->db->query($sql);
if (!$result) {
$error++;
$this->errors[] = $this->db->lasterror();
}
}
if (!$error) {
$this->db->commit();
return 1;
} else {