Merge pull request #26043 from hregis/fix_trigger_delete

FIX missing contact_id for the trigger
This commit is contained in:
Laurent Destailleur 2023-09-27 15:31:12 +02:00 committed by GitHub
commit 46d4e83b5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -512,6 +512,8 @@ Following changes may create regressions for some external modules, but were nec
* v14 seems to work correctly on PHP v8 but it generates a lot of verbose warnings. Currently, v14 i snot yet officialy supported with PHP 8.
* To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in
method executeCLI() available into core/class/utils.class.php
* the trigger "*_DELETE_CONTACT" inside "delete_contact()" function from commonobject.class.php is call before delete the object element
and a $object->context['contact_id'] is now available for this trigger
***** ChangeLog for 13.0.5 compared to 13.0.4 *****

View file

@ -1176,6 +1176,7 @@ abstract class CommonObject
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++;
@ -1184,6 +1185,8 @@ abstract class CommonObject
}
if (!$error) {
dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql .= " WHERE rowid = ".((int) $rowid);