Fix #38563 skip task-driven project load when allprojects view fetch returns no row (#38565)

* Fix #38563 skip task-driven project load when allprojects view fetch returns no row

The updateline handler at htdocs/projet/tasks/time.php line 302 populates
$object via Task::fetch($id_temp) where $id_temp is the edited line's
task id. After the save, the page falls through to the render block at
line 937. In the all-projects view ($id=0, $ref=''), the outer if is
entered only because $allprojectforuser is set, then the elseif tests
$object->fetch($id, $ref) >= 0. Task::fetch returns 0 for no row but
leaves prior properties untouched, so $object->fk_project carries the
edited task's project. $projectstatic loads that project, $arrayofmassactions
gets filled, and the per-row toselect[] checkbox renders on every row
of the all-projects list, including rows for other projects.

Tighten the guard to > 0 so the body only runs when fetch actually
returned a row. The all-projects list then keeps the same render state
it had before the line edit: no projectstatic load, no massactions.

Reported by @priojk. Same code path on 23.0 and develop; 22.0 has a
different structure for this block and is not affected.

Signed-off-by: Dolicraft <contact@dolicraft.com>

* Update time.php

---------

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
w3houde 2026-06-02 04:00:48 +07:00 committed by GitHub
parent 33608619ff
commit 01472ecdff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -942,7 +942,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$projectstatic->fetch_thirdparty();
}
$res = $projectstatic->fetch_optionals();
} elseif ($object->fetch($id, $ref) >= 0) {
} elseif ($object->fetch($id, $ref) > 0) {
if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_TASK') && empty($object->comments)) {
$object->fetchComments();
}