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]
[步骤]