Finish removal of duplicate hook/trigger

This commit is contained in:
Laurent Destailleur 2020-04-23 12:54:28 +02:00
parent 46716f2259
commit 4475df14b4
3 changed files with 37 additions and 72 deletions

View File

@ -210,22 +210,11 @@ class CommandeFournisseurDispatch extends CommonObject
} }
} }
// Actions on extra fields (by external module or standard code) // Create extrafields
// TODO le hook fait double emploi avec le trigger !! if (! $error)
$hookmanager->initHooks(array('commandefournisseurdispatchdao'));
$parameters = array('id'=>$this->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$this->insertExtraFields();
{ if ($result < 0) $error++;
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
} }
// Commit or rollback // Commit or rollback

View File

@ -186,26 +186,21 @@ if (empty($reshook))
if ($action == 'update_extras') if ($action == 'update_extras')
{ {
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form // Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute')); $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (!$error) if (!$error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! $result = $object->insertExtraFields('RECEPTION_MODIFY');
$hookmanager->initHooks(array('receptiondao'));
$parameters = array('id' => $object->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) {
$result = $object->insertExtraFields();
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} elseif ($reshook < 0)
$error++;
} }
if ($error) if ($error)

View File

@ -305,24 +305,12 @@ class Reception extends CommonObject
} }
} }
// Actions on extra fields (by external module or standard code) // Create extrafields
// TODO le hook fait double emploi avec le trigger !! if (! $error)
$action = 'add';
$hookmanager->initHooks(array('receptiondao'));
$parameters = array('socid'=>$this->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$this->insertExtraFields();
{ if ($result < 0) $error++;
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
} }
}
}
elseif ($reshook < 0) $error++;
if (!$error && !$notrigger) if (!$error && !$notrigger)
{ {
@ -330,6 +318,7 @@ class Reception extends CommonObject
$result = $this->call_trigger('RECEPTION_CREATE', $user); $result = $this->call_trigger('RECEPTION_CREATE', $user);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// End call triggers // End call triggers
}
if (!$error) if (!$error)
{ {
@ -348,14 +337,6 @@ class Reception extends CommonObject
} }
} }
else else
{
$error++;
$this->error = $this->db->lasterror()." - sql=$sql";
$this->db->rollback();
return -3;
}
}
else
{ {
$error++; $error++;
$this->error = $this->db->lasterror()." - sql=$sql"; $this->error = $this->db->lasterror()." - sql=$sql";