diff --git a/module/story/model.php b/module/story/model.php index fd30ae9512..dfb17f9725 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2053,7 +2053,20 @@ class storyModel extends model $this->dao->insert(TABLE_TASKSPEC)->data($taskSpec)->autoCheck()->exec(); if(dao::isError()) return false; - if($task->story) $this->setStage($task->story); + if($task->story) + { + $this->setStage($task->story); + if($this->config->edition != 'open') + { + $relation = new stdClass(); + $relation->relation = 'generated'; + $relation->AID = $task->story; + $relation->AType = 'story'; + $relation->BID = $taskID; + $relation->BType = 'task'; + $this->dao->replace(TABLE_RELATION)->data($relation)->exec(); + } + } $this->action->create('task', $taskID, 'Opened', ''); } diff --git a/module/task/model.php b/module/task/model.php index 57eaf5e42e..eddc152ac1 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -510,7 +510,21 @@ class taskModel extends model if(!$taskID) return false; /* Update Kanban and story stage. */ - if(!empty($task->story)) $this->story->setStage($task->story); + if(!empty($task->story)) + { + $this->story->setStage($task->story); + + if($this->config->edition != 'open') + { + $relation = new stdClass(); + $relation->relation = 'generated'; + $relation->AID = $task->story; + $relation->AType = 'story'; + $relation->BID = $taskID; + $relation->BType = 'task'; + $this->dao->replace(TABLE_RELATION)->data($relation)->exec(); + } + } $this->updateKanbanForBatchCreate($taskID, $executionID, $laneID, (int)$columnID); $taskIdList[$taskID] = $taskID; diff --git a/module/upgrade/model.php b/module/upgrade/model.php index b530085646..815be98257 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -10069,16 +10069,26 @@ class upgradeModel extends model } /* Process bug transferred to task. */ - $bugTransferredToTask = $this->dao->select('id,fromBug')->from(TABLE_TASK)->where('fromBug')->ne(0)->fetchPairs('id'); - foreach($bugTransferredToTask as $taskID => $bugID) + $taskList = $this->dao->select('id,story,fromBug')->from(TABLE_TASK)->where('fromBug')->ne(0)->orWhere('story')->ne(0)->fetchAll('id'); + foreach($taskList as $taskID => $task) { $relation = new stdClass(); - $relation->AType = 'bug'; - $relation->AID = $bugID; - $relation->relation = 'transferredto'; $relation->BType = 'task'; $relation->BID = $taskID; - $this->dao->replace(TABLE_RELATION)->data($relation)->exec(); + if(!empty($task->fromBug)) + { + $relation->relation = 'transferredto'; + $relation->AType = 'bug'; + $relation->AID = $task->fromBug; + $this->dao->replace(TABLE_RELATION)->data($relation)->exec(); + } + if(!empty($task->story)) + { + $relation->relation = 'generated'; + $relation->AType = 'story'; + $relation->AID = $task->story; + $this->dao->replace(TABLE_RELATION)->data($relation)->exec(); + } } /* Process bug transferred to story. */