diff --git a/ChangeLog b/ChangeLog index 0ac6d7906a6..b8c397b4bf7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,7 +19,7 @@ WARNING: The following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The directory /build has been moved into /dev/build. * The use of GETPOST function is not allowed inside extrafields conditions or any strings that contains dynamic code evaluated with dol_eval() - +* The deprecated variable $trigger_name (duplicate of variable $triggersendname) has been removed. You must use $triggersendname everywhere now. ***** ChangeLog for 21.0.0 compared to 20.0 ***** diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index a3490213b80..1bb49a384e7 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -7488,12 +7488,6 @@ parameters: count: 1 path: ../../../htdocs/core/actions_sendmails.inc.php - - - message: '#^Variable \$paramname2 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/actions_sendmails.inc.php - - message: '#^Variable \$result might not be defined\.$#' identifier: variable.undefined diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index dc79e395697..bb52fb19522 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2667,11 +2667,11 @@ class Propal extends CommonObject if ($resql) { // Status self::STATUS_REFUSED by default $modelpdf = getDolGlobalString('PROPALE_ADDON_PDF_ODT_CLOSED', $this->model_pdf); - $trigger_name = 'PROPAL_CLOSE_REFUSED'; // used later in call_trigger() + $triggersendname = 'PROPAL_CLOSE_REFUSED'; // used later in call_trigger() - if ($status == self::STATUS_SIGNED) { // Status self::STATUS_SIGNED - $trigger_name = 'PROPAL_CLOSE_SIGNED'; // used later in call_trigger() - $modelpdf = getDolGlobalString('PROPALE_ADDON_PDF_ODT_TOBILL') ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->model_pdf; + if ($status == self::STATUS_SIGNED) { // Status self::STATUS_SIGNED + $triggersendname = 'PROPAL_CLOSE_SIGNED'; // used later in call_trigger() + $modelpdf = getDolGlobalString('PROPALE_ADDON_PDF_ODT_TOBILL', $this->model_pdf); // The connected company is classified as a client $soc = new Societe($this->db); diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 63111a9782c..61d0e6752d0 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -24,24 +24,25 @@ * \brief Code for actions on sending mails from object page */ -// $mysoc must be defined -// $id must be defined -// $paramname may be defined -// $autocopy may be defined (used to know the automatic BCC to add) -// $triggersendname must be set (can be '') -// $actiontypecode can be set -// $object and $subject may be defined /** + * @var Societe $mysoc * @var CommonObject $object * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager * @var Societe $mysoc * @var Translate $langs + * @var User $user * - * @var string $dolibarr_main_url_root - * @var string $action + * @var int $id + * @var string $dolibarr_main_url_root + * @var string $action * @var ?string $subject + * @var ?string $triggersendname (can be '') + * @var ?string $sendcontext + * @var ?string $autocopy (used to know the automatic BCC to add) + * @var ?string $actiontypecode + * @var ?string $paramname */ ' @phan-var-force Societe $mysoc @@ -446,9 +447,9 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO $object->email_tocc = $sendtocc; $object->email_tobcc = $sendtobcc; - // Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated) - if (!empty($triggersendname) || !empty($trigger_name)) { - $result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user); // @phan-suppress-current-line PhanPossiblyUndeclaredGlobalVariable + // Call of triggers (you should have set $triggersendname to execute trigger. + if (!empty($triggersendname)) { + $result = $object->call_trigger($triggersendname, $user); // @phan-suppress-current-line PhanPossiblyUndeclaredGlobalVariable if ($result < 0) { $error++; } @@ -464,12 +465,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); setEventMessages($mesg, null, 'mesgs'); - $moreparam = ''; - if (isset($paramval2)) { // @phan-var-suppress-current-line PhanPluginUndeclaredVariableIsset - // @phan-var-suppress-next-line PhanUndeclaredGlobalVariable - $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2; - } - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ?? 'id').'='.(is_object($object) ? $object->id : '').$moreparam); + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ?? 'id').'='.(is_object($object) ? $object->id : '')); exit; } else { $langs->load("other");