在以下代码片段中,while循环在条件变为false时不会停止。
public function isCircularDependancy($taskId, $newParentId){
global $pdoHandlerObject;
$task = $this->getTaskById($taskId);
if($newParentId == 0){ // This is root task there is no parent
return false;
}
if($task->parent_id == $newParentId){ // Parent is not changed
return false;
}
$currentParentId = $newParentId;
while($currentParentId != 0){
if($currentParentId == $task->id){
return true;
}
$currentParent = $this->getTaskById($currentParentId);
$currentPatentId = $currentParent->parent_id;
}
return false;
}