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 <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
This commit is contained in:
w3houde 2026-06-11 09:32:37 +02:00 committed by GitHub
parent 3424914d8b
commit 4cacecdbdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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");