diff --git a/module/bug/model.php b/module/bug/model.php index c0d36c6161..78ae812228 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -339,25 +339,36 @@ class bugModel extends model if($this->config->edition != 'open') { - if($oldBug->story > 0) + if($oldBug->story > 0 || $oldBug->task > 0) { + $AID = $oldBug->story > 0 ? ($oldBug->task > 0 ? "{$oldBug->story},{$oldBug->task}" : $oldBug->story) : $oldBug->task; + $AType = $oldBug->story > 0 ? ($oldBug->task > 0 ? 'story,task' : 'story') : 'task'; $this->dao->delete()->from(TABLE_RELATION) ->where('relation')->eq('generated') - ->andWhere('AID')->eq($oldBug->story) - ->andWhere('AType')->eq('story') + ->andWhere('AID')->in($AID) + ->andWhere('AType')->in($AType) ->andWhere('BID')->eq($oldBug->id) ->andWhere('BType')->eq('bug') ->exec(); } - if($bug->story > 0) + if($bug->story > 0 || $bug->task > 0) { $relation = new stdClass(); - $relation->AID = $bug->story; - $relation->AType = 'story'; $relation->relation = 'generated'; $relation->BID = $bug->id; $relation->BType = 'bug'; - $this->dao->replace(TABLE_RELATION)->data($relation)->exec(); + if($bug->story > 0) + { + $relation->AID = $bug->story; + $relation->AType = 'story'; + $this->dao->replace(TABLE_RELATION)->data($relation)->exec(); + } + if($bug->task > 0) + { + $relation->AID = $bug->task; + $relation->AType = 'task'; + $this->dao->replace(TABLE_RELATION)->data($relation)->exec(); + } } } diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 5d9509dbce..261b0bd4c9 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -10022,7 +10022,7 @@ class upgradeModel extends model } /* Process bug link bug. */ - $bugList = $this->dao->select('id,story,relatedBug')->from(TABLE_BUG)->where('relatedBug')->ne('')->orWhere('story')->ne('0')->fetchAll('id'); + $bugList = $this->dao->select('id,story,relatedBug,task')->from(TABLE_BUG)->where('relatedBug')->ne('')->orWhere('story')->ne(0)->orWhere('task')->ne(0)->fetchAll('id'); foreach($bugList as $bugID => $bug) { if(!empty($bug->relatedBug)) @@ -10049,6 +10049,16 @@ class upgradeModel extends model $relation->BID = $bugID; $this->dao->replace(TABLE_RELATION)->data($relation)->exec(); } + if(!empty($bug->task)) + { + $relation = new stdClass(); + $relation->AType = 'task'; + $relation->AID = $bug->task; + $relation->relation = 'generated'; + $relation->BType = 'bug'; + $relation->BID = $bugID; + $this->dao->replace(TABLE_RELATION)->data($relation)->exec(); + } } /* Process case link case. */