diff --git a/module/bug/control.php b/module/bug/control.php index a48fc1ec09..b475b2f01e 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1133,10 +1133,35 @@ class bug extends control { if($this->post->bugIDList) { - $bugIDList = $this->post->bugIDList; - $bugIDList = array_unique($bugIDList); + $bugIDList = $this->post->bugIDList; + $bugIDList = array_unique($bugIDList); + $oldBugs = $this->bug->getByList($bugIDList); + $skipBugIDList = ''; unset($_POST['bugIDList']); - $allChanges = $this->bug->batchChangeBranch($bugIDList, $branchID); + + /* Remove condition mismatched bugs. */ + foreach($bugIDList as $key => $bugID) + { + $oldBug = $oldBugs[$bugID]; + if($branchID == $oldBug->branch) + { + unset($bugIDList[$key]); + continue; + } + elseif($branchID != $oldBug->branch and !empty($oldBug->module)) + { + $skipBugIDList .= '[' . $bugID . ']'; + unset($bugIDList[$key]); + continue; + } + } + + if(!empty($skipBugIDList)) + { + echo js::alert(sprintf($this->lang->bug->noSwitchBranch, $skipBugIDList)); + } + + $allChanges = $this->bug->batchChangeBranch($bugIDList, $branchID, $oldBugs); if(dao::isError()) die(js::error(dao::getError())); foreach($allChanges as $bugID => $changes) { diff --git a/module/bug/lang/en.php b/module/bug/lang/en.php index cfb0dba87c..1a37219fd3 100644 --- a/module/bug/lang/en.php +++ b/module/bug/lang/en.php @@ -192,6 +192,7 @@ $lang->bug->skipClose = 'Bug %s is active. You cannot close it.'; $lang->bug->executionAccessDenied = "You access to the {$lang->executionCommon} to which this bug belongs is denied!"; $lang->bug->stepsNotEmpty = "The reproduction step cannot be empty."; $lang->bug->confirmUnlinkBuild = "Replacing the solution version will disassociate the bug from the old version. Are you sure you want to disassociate the bug from %s?"; +$lang->bug->noSwitchBranch = 'The linked module of Bug%s is not in the current branch. It will be omitted.'; /* Template. */ $lang->bug->tplStep = "

[Steps]


"; diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php index 058bd29008..0aa5536766 100644 --- a/module/bug/lang/zh-cn.php +++ b/module/bug/lang/zh-cn.php @@ -192,6 +192,7 @@ $lang->bug->skipClose = 'Bug %s 不是已解决状态,不能关闭 $lang->bug->executionAccessDenied = "您无权访问该Bug所属的{$lang->executionCommon}!"; $lang->bug->stepsNotEmpty = "重现步骤不能为空。"; $lang->bug->confirmUnlinkBuild = "更换解决版本将取消与旧版本的关联,您确定取消该bug与%s的关联吗?"; +$lang->bug->noSwitchBranch = 'Bug%s所属模块不在当前分支下,将自动忽略。'; /* 模板。*/ $lang->bug->tplStep = "

[步骤]


"; diff --git a/module/bug/model.php b/module/bug/model.php index 8e8b91b1a1..33f99c0160 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1043,18 +1043,17 @@ class bugModel extends model * * @param array $bugIDList * @param int $branchID + * @param array $oldBugs * @access public * @return array */ - public function batchChangeBranch($bugIDList, $branchID) + public function batchChangeBranch($bugIDList, $branchID, $oldBugs) { $now = helper::now(); $allChanges = array(); - $oldBugs = $this->getByList($bugIDList); foreach($bugIDList as $bugID) { $oldBug = $oldBugs[$bugID]; - if($branchID == $oldBug->branch) continue; $bug = new stdclass(); $bug->lastEditedBy = $this->app->user->account;