diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 4413e9b3361..ebc887ccbb6 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -712,21 +712,22 @@ class Project extends CommonObject } /** - * Reoder tasks to delete children tasks first + * Delete tasks with no children first, then task with children recursively * - * @param array $arr Array of tasks + * @param int <0 if KO, 1 if OK */ function deleteTasks($user) { $countTasks = count($this->lines); $deleted = false; - if ($countTasks){ + if ($countTasks) + { foreach($this->lines as $task) { - if($task->hasChildren() <= 0) { + if ($task->hasChildren() <= 0) { // If there is no children (or error to detect them) $deleted = true; $ret = $task->delete($user); - if ($ret < 1) + if ($ret <= 0) { $this->errors[] = $this->db->lasterror(); return -1; @@ -735,7 +736,7 @@ class Project extends CommonObject } } $this->getLinesArray($user); - if($deleted && count($this->lines) < $countTasks) + if ($deleted && count($this->lines) < $countTasks) { if (count($this->lines)) $this->deleteTasks($this->lines); }