From 4cacecdbdc7fbf007475019ad7b669fc451a0fa5 Mon Sep 17 00:00:00 2001 From: w3houde Date: Thu, 11 Jun 2026 09:32:37 +0200 Subject: [PATCH] Fix #34630 keep existing fk_user on timespent update when 'by' column is hidden (#38688) When the 'by' column is hidden in the project timespent list, the form does not emit a userid_line input. The updateline handler then read GETPOSTINT('userid_line') as 0 and overwrote timespent_fk_user. The downstream 'in_array($object->timespent_fk_user, $childids)' guard with fk_user=0 blocked the update and the user saw a confusing 'Field User is required' for the unchanged user assignment. Only overwrite timespent_fk_user when the form actually posted userid_line, mirroring the date column fix from #34511. Signed-off-by: Dolicraft Co-authored-by: Dolicraft --- htdocs/projet/tasks/time.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 419229211e0..480f01f32e2 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -313,7 +313,10 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_date = $timespent_date; $object->timespent_withhour = 0; } - $object->timespent_fk_user = GETPOSTINT("userid_line"); + // If column "by" is hidden, no userid_line is posted; keep the existing fk_user instead of resetting it to 0. + if (GETPOSTISSET("userid_line")) { + $object->timespent_fk_user = GETPOSTINT("userid_line"); + } $object->timespent_fk_product = GETPOSTINT("fk_product"); $object->timespent_invoiceid = GETPOSTINT("invoiceid"); $object->timespent_invoicelineid = GETPOSTINT("invoicelineid"); @@ -348,7 +351,10 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_withhour = 0; } - $object->timespent_fk_user = GETPOSTINT("userid_line"); + // If column "by" is hidden, no userid_line is posted; keep the existing fk_user instead of resetting it to 0. + if (GETPOSTISSET("userid_line")) { + $object->timespent_fk_user = GETPOSTINT("userid_line"); + } $object->timespent_fk_product = GETPOSTINT("fk_product"); $object->timespent_invoiceid = GETPOSTINT("invoiceid"); $object->timespent_invoicelineid = GETPOSTINT("invoicelineid");