16.0 - Proposal for trigger prefix consistency: instead of adding missing prefix, check that trigger starts with declared prefix
This commit is contained in:
parent
96c432566d
commit
563716b633
@ -1988,10 +1988,6 @@ abstract class CommonObject
|
|||||||
$result = $this->fetchCommon($id);
|
$result = $this->fetchCommon($id);
|
||||||
}
|
}
|
||||||
if ($result >= 0) {
|
if ($result >= 0) {
|
||||||
|
|
||||||
if (!empty(self::TRIGGER_PREFIX) && strpos($trigkey, self::TRIGGER_PREFIX) !== 0) {
|
|
||||||
$trigkey = self::TRIGGER_PREFIX . '_' . $trigkey;
|
|
||||||
}
|
|
||||||
$result = $this->call_trigger($trigkey, (!empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors
|
$result = $this->call_trigger($trigkey, (!empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors
|
||||||
}
|
}
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
@ -4274,9 +4270,6 @@ abstract class CommonObject
|
|||||||
|
|
||||||
if ($trigkey) {
|
if ($trigkey) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
if (!empty(self::TRIGGER_PREFIX) && strpos($trigkey, self::TRIGGER_PREFIX) !== 0) {
|
|
||||||
$trigkey = self::TRIGGER_PREFIX . '_' . $trigkey;
|
|
||||||
}
|
|
||||||
$result = $this->call_trigger($trigkey, $user);
|
$result = $this->call_trigger($trigkey, $user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
@ -5610,9 +5603,8 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
if (!empty(self::TRIGGER_PREFIX) && strpos($triggerName, self::TRIGGER_PREFIX . '_') !== 0) {
|
||||||
if (!empty(self::TRIGGER_PREFIX) && strpos($triggerName, self::TRIGGER_PREFIX) !== 0) {
|
throw new Exception('The trigger "' . $triggerName . '" does not start with "' . self::TRIGGER_PREFIX . '_" as required.');
|
||||||
$triggerName = self::TRIGGER_PREFIX . '_' . $triggerName;
|
|
||||||
}
|
}
|
||||||
if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers.
|
if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers.
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
||||||
@ -6201,9 +6193,6 @@ abstract class CommonObject
|
|||||||
if (!$error && $trigger) {
|
if (!$error && $trigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$this->context = array('extrafieldaddupdate'=>1);
|
$this->context = array('extrafieldaddupdate'=>1);
|
||||||
if (!empty(self::TRIGGER_PREFIX) && strpos($trigger, self::TRIGGER_PREFIX) !== 0) {
|
|
||||||
$trigger = self::TRIGGER_PREFIX . '_' . $trigger;
|
|
||||||
}
|
|
||||||
$result = $this->call_trigger($trigger, $userused);
|
$result = $this->call_trigger($trigger, $userused);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
@ -6322,9 +6311,6 @@ abstract class CommonObject
|
|||||||
if (!$error && $trigger) {
|
if (!$error && $trigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$this->context = array('extralanguagesaddupdate'=>1);
|
$this->context = array('extralanguagesaddupdate'=>1);
|
||||||
if (!empty(self::TRIGGER_PREFIX) && strpos($trigger, self::TRIGGER_PREFIX) !== 0) {
|
|
||||||
$trigger = self::TRIGGER_PREFIX . '_' . $trigger;
|
|
||||||
}
|
|
||||||
$result = $this->call_trigger($trigger, $userused);
|
$result = $this->call_trigger($trigger, $userused);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
@ -6523,10 +6509,6 @@ abstract class CommonObject
|
|||||||
if (!$error && $trigger) {
|
if (!$error && $trigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$this->context = array('extrafieldupdate'=>1);
|
$this->context = array('extrafieldupdate'=>1);
|
||||||
|
|
||||||
if (!empty(self::TRIGGER_PREFIX) && strpos($trigger, self::TRIGGER_PREFIX) !== 0) {
|
|
||||||
$trigger = self::TRIGGER_PREFIX . '_' . $trigger;
|
|
||||||
}
|
|
||||||
$result = $this->call_trigger($trigger, $userused);
|
$result = $this->call_trigger($trigger, $userused);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
@ -9447,10 +9429,6 @@ abstract class CommonObject
|
|||||||
|
|
||||||
if (!$error && !$notrigger) {
|
if (!$error && !$notrigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
|
|
||||||
if (!empty(self::TRIGGER_PREFIX) && strpos($triggercode, self::TRIGGER_PREFIX) !== 0) {
|
|
||||||
$triggercode = self::TRIGGER_PREFIX . '_' . $triggercode;
|
|
||||||
}
|
|
||||||
$result = $this->call_trigger($triggercode, $user);
|
$result = $this->call_trigger($triggercode, $user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user