Merge pull request #17140 from atm-gauthier/develop_fix_cant_update_task_if_closed_project

FIX : we can't update task if closed project because of wrong test wi…
This commit is contained in:
Laurent Destailleur 2021-04-06 19:27:12 +02:00 committed by GitHub
commit f08b0be9f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -402,18 +402,20 @@ class Task extends CommonObject
if (!$error && !empty($conf->global->PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE)) {
// Close the parent project if it is open (validated) and its tasks are 100% completed
$project = new Project($this->db);
if ($project->fetch($this->fk_project) > 0 && $project->statut == Project::STATUS_VALIDATED) {
$project->getLinesArray(null); // this method does not return <= 0 if fails
$projectCompleted = array_reduce(
$project->lines,
function ($allTasksCompleted, $task) {
return $allTasksCompleted && $task->progress >= 100;
},
if ($project->fetch($this->fk_project) > 0) {
if ($project->statut == Project::STATUS_VALIDATED) {
$project->getLinesArray(null); // this method does not return <= 0 if fails
$projectCompleted = array_reduce(
$project->lines,
function ($allTasksCompleted, $task) {
return $allTasksCompleted && $task->progress >= 100;
},
1
);
if ($projectCompleted) {
if ($project->setClose($user) <= 0) {
$error++;
);
if ($projectCompleted) {
if ($project->setClose($user) <= 0) {
$error++;
}
}
}
} else {