Fix project::delete to delete children tasks before parent tasks
This commit is contained in:
parent
e85ec19018
commit
4e16f64af0
@ -633,9 +633,7 @@ class Project extends CommonObject
|
|||||||
$this->getLinesArray($user);
|
$this->getLinesArray($user);
|
||||||
|
|
||||||
// Delete tasks
|
// Delete tasks
|
||||||
foreach($this->lines as &$task) {
|
$this->deleteTasks($this->lines);
|
||||||
$task->delete($user);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete project
|
// Delete project
|
||||||
if (! $error)
|
if (! $error)
|
||||||
@ -711,6 +709,25 @@ class Project extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reoder tasks to delete children tasks first
|
||||||
|
*
|
||||||
|
* @param array $arr Array of tasks
|
||||||
|
*/
|
||||||
|
function deleteTasks($arr)
|
||||||
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
$arrParents = array();
|
||||||
|
foreach($arr as $task)
|
||||||
|
{
|
||||||
|
if($task->hasChildren() < 0) $task->delete($user);
|
||||||
|
else $arrParents[] = $task;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($arrParents)) $this->deleteTasks($arrParents);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a project
|
* Validate a project
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user