FIX wrong place of trigger delete
This commit is contained in:
parent
c2b9ea2192
commit
bcc97f8b9f
1 changed files with 20 additions and 11 deletions
|
|
@ -1170,22 +1170,31 @@ abstract class CommonObject
|
|||
// phpcs:enable
|
||||
global $user;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_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
|
||||
$result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue