From 296b33aa977f1023a4792c12f6da276deeb95c4f Mon Sep 17 00:00:00 2001 From: w3houde Date: Thu, 25 Jun 2026 21:35:03 +0200 Subject: [PATCH] Fix #37663 guard SUBTOTALS_SPECIAL_CODE before use in printOriginLine (#38817) SUBTOTALS_SPECIAL_CODE is only defined by the subtotals module (htdocs/subtotals/class/commonsubtotal.class.php:24). When a PO line is printed into a vendor invoice create screen and the subtotals module is not loaded for the current request, htdocs/core/class/commonobject.class.php line 5872 fatals with 'Undefined constant SUBTOTALS_SPECIAL_CODE', hiding every origin line. Wrap the comparison with defined() to match the existing pattern used in objectline_view.tpl.php:81, objectline_edit.tpl.php:71 and originproductline.tpl.php:50. Signed-off-by: Dolicraft Co-authored-by: Dolicraft --- htdocs/core/class/commonobject.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 09309c16e7d..f27a2a7673f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5869,7 +5869,11 @@ abstract class CommonObject $this->tpl['strike'] = 0; if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) { $this->tpl['strike'] = 1; - } elseif ($line->special_code == SUBTOTALS_SPECIAL_CODE) { + } elseif (defined('SUBTOTALS_SPECIAL_CODE') && $line->special_code == SUBTOTALS_SPECIAL_CODE) { + // SUBTOTALS_SPECIAL_CODE is only defined when the subtotals module + // is loaded (htdocs/subtotals/class/commonsubtotal.class.php:24). + // Without the guard, printing origin lines from a PO into a vendor + // invoice fatals (#37663). Other tpl files already follow this pattern. $this->tpl['strike'] = 1; }