diff --git a/module/bug/model.php b/module/bug/model.php index eb26511faf..6d44b10346 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -865,11 +865,10 @@ class bugModel extends model ->where('id')->eq($bugID)->exec(); $relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID); - $attribute = new stdclass(); + $attribute = $this->getByID($bugID); $attribute->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $bug->assignedTo); if($attribute->assignee_id != '') { - $attribute = $this->getByID($bugID); // TODO(dingguodong) we should alert to operator when can not find the user, and the operator should reconfigure user binding. $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $attribute); } @@ -1255,7 +1254,7 @@ class bugModel extends model if($singleIssue->state != 'closed') { - $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $object); + if(!empty($object)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $object); } } return common::createChanges($oldBug, $bug); diff --git a/module/story/model.php b/module/story/model.php index cd371d2727..74b94499f3 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -838,7 +838,7 @@ class storyModel extends model $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); if($relation) { - $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $object); + $if(!empty($object)) this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $object); } } @@ -1435,6 +1435,7 @@ class storyModel extends model ->checkIF($story->closedReason == 'duplicate', 'duplicateStory', 'notempty') ->where('id')->eq($storyID)->exec(); + $object = $this->getByID($storyID); $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); if(!empty($relation)) @@ -1444,11 +1445,9 @@ class storyModel extends model if($singleIssue->state != 'closed') { - $object = $this->getByID($storyID); - $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $object); + $if(!empty($object)) this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $object); } } - /* Update parent story status. */ if($oldStory->parent > 0) $this->updateParentStatus($storyID, $oldStory->parent); @@ -1794,11 +1793,10 @@ class storyModel extends model if(!dao::isError()) { $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); - $attribute = new stdclass(); + $attribute = $this->getByID($storyID); $attribute->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $story->assignedTo); if($attribute->assignee_id != '') { - $object = $this->getByID($storyID); // TODO(dingguodong) we should alert to operator when can not find the user, and the operator should reconfigure user binding. $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story' $attribute); } @@ -1841,7 +1839,7 @@ class storyModel extends model $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); if($relation) { - $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $object); + $if(!empty($object)) this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $object); } } } diff --git a/module/task/model.php b/module/task/model.php index 78512624d1..e3c19189d7 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -958,8 +958,7 @@ class taskModel extends model $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); if($relation) { - $object = $this->getByID($taskID); - $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $object); + if(!empty($object)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $object); } } @@ -1350,11 +1349,10 @@ class taskModel extends model ->where('id')->eq($taskID)->exec(); $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); - $attribute = new stdclass(); + $attribute = $this->getByID($taskID); $attribute->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $task->assignedTo); if($attribute->assignee_id != '') { - $attribute = $this->getByID($taskID); // TODO(dingguodong) we should alert to operator when can not find the user, and the operator should reconfigure user binding. $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, $attribute); } @@ -1763,6 +1761,7 @@ class taskModel extends model $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->where('id')->eq((int)$taskID)->exec(); + $object = $this->getByID($bugID); $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); if(!empty($relation)) { @@ -1771,7 +1770,6 @@ class taskModel extends model if($singleIssue->state != 'closed') { - $object = $this->getByID($bugID); if(!empty($object)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $object); } } @@ -1820,6 +1818,7 @@ class taskModel extends model } if($oldTask->story) $this->loadModel('story')->setStage($oldTask->story); + $object = $this->getByID($taskID); $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); if(!empty($relation)) { @@ -1828,8 +1827,7 @@ class taskModel extends model if($singleIssue->state != 'closed') { - $object = $this->getByID($taskID); - $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $object); + $if(!empty($object)) this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $object); } }