From ba6f7d4b0a1daba4ab391e76fc39d30eefe84699 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 14 Aug 2018 09:32:43 +0200 Subject: [PATCH] fix infinite loop --- htdocs/projet/class/project.class.php | 32 ++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 2292487898d..4413e9b3361 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -633,7 +633,8 @@ class Project extends CommonObject $this->getLinesArray($user); // Delete tasks - $this->deleteTasks($this->lines); + $ret = $this->deleteTasks($user); + if ($ret < 0) $error++; // Delete project if (! $error) @@ -715,16 +716,31 @@ class Project extends CommonObject * * @param array $arr Array of tasks */ - function deleteTasks($arr) + function deleteTasks($user) { - global $user; - - foreach($arr as $task) - { - if($task->hasChildren() <= 0) $task->delete($user); + $countTasks = count($this->lines); + $deleted = false; + if ($countTasks){ + foreach($this->lines as $task) + { + if($task->hasChildren() <= 0) { + $deleted = true; + $ret = $task->delete($user); + if ($ret < 1) + { + $this->errors[] = $this->db->lasterror(); + return -1; + } + } + } } $this->getLinesArray($user); - if (count($this->lines)) $this->deleteTasks($this->lines); + if($deleted && count($this->lines) < $countTasks) + { + if (count($this->lines)) $this->deleteTasks($this->lines); + } + + return 1; } /**