From a8d4067af26f4407741d1d444a8dcc38e414c2f1 Mon Sep 17 00:00:00 2001 From: Benjamin Chanudet Date: Fri, 22 Aug 2025 05:18:25 +0200 Subject: [PATCH] FIX #35011 Computed extrafield on tasks list now display correct values (#35038) The functions assigns value to `$obj` on line 976, but doesn't assign value to `$object`, that is then assigned to `$objectoffield` in line 75 of `extrafields_list_print_fields.tpl.php`. Also `$objectoffield` is the recommended value to use for computed extrafields, according to the docs. But assigning `$object` is not enough, because `$objectoffield` at this moment is not grabbed from the global scope, so the value stays local and `dol_eval()` doesn't find it. So it also needs to grab the variable from the global scope to affect it correctly. The changed function, `projectLinesa()` is called only twice in the project: by itself recursively to go through all subtasks, and on the page where I detected the bug initially, `tasks.php`, so the impact should be minimal. --- htdocs/core/lib/project.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 23ae5d8b032..931fd08680b 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -600,6 +600,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t { global $user, $langs, $conf, $db, $hookmanager; global $projectstatic, $taskstatic, $extrafields; + global $objectoffield; $lastprojectid = 0; @@ -936,6 +937,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $extrafieldsobjectkey = $taskstatic->table_element; $extrafieldsobjectprefix = 'efpt.'; $obj = $lines[$i]; + $object = $lines[$i]; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook $parameters = array('arrayfields' => $arrayfields, 'obj' => $lines[$i]);