From f8f763f9dd0511451da20d90acfc7e9703d13e8c Mon Sep 17 00:00:00 2001 From: mayue Date: Thu, 23 Dec 2021 14:15:27 +0800 Subject: [PATCH 1/2] * Fix a bug #17638. --- module/bug/control.php | 5 +---- module/bug/model.php | 30 ------------------------------ 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 87432af5c1..8afc84a762 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -181,9 +181,6 @@ class bug extends control /* Process bug for check story changed. */ $bugs = $this->loadModel('story')->checkNeedConfirm($bugs); - /* Process the openedBuild and resolvedBuild fields. */ - $bugs = $this->bug->processBuildForBugs($bugs); - /* Get story and task id list. */ $storyIdList = $taskIdList = array(); foreach($bugs as $bug) @@ -1466,7 +1463,7 @@ class bug extends control $this->view->users = $users; $this->view->assignedTo = $assignedTo; $this->view->executions = $this->loadModel('product')->getExecutionPairsByProduct($productID, $bug->branch ? "0,{$bug->branch}" : 0, 'id_desc', $projectID); - $this->view->builds = $this->loadModel('build')->getBuildPairs($productID, 'all', 'withbranch'); + $this->view->builds = $this->loadModel('build')->getBuildPairs($productID, $bug->branch, 'withbranch'); $this->view->actions = $this->action->getList('bug', $bugID); $this->display(); } diff --git a/module/bug/model.php b/module/bug/model.php index 246ebaedda..3d7fa64eda 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1375,36 +1375,6 @@ class bugModel extends model $this->loadModel('search')->setSearchParams($this->config->bug->search); } - /** - * Process the openedBuild and resolvedBuild fields for bugs. - * - * @param array $bugs - * @access public - * @return array - */ - public function processBuildForBugs($bugs) - { - $productIdList = array(); - foreach($bugs as $bug) $productIdList[$bug->id] = $bug->product; - $builds = $this->loadModel('build')->getBuildPairs(array_unique($productIdList), 0, $params = ''); - - /* Process the openedBuild and resolvedBuild fields. */ - foreach($bugs as $key => $bug) - { - $openBuildIdList = explode(',', $bug->openedBuild); - $openedBuild = ''; - foreach($openBuildIdList as $buildID) - { - $openedBuild .= isset($builds[$buildID]) ? $builds[$buildID] : $buildID; - $openedBuild .= ','; - } - $bug->openedBuild = rtrim($openedBuild, ','); - $bug->resolvedBuild = isset($builds[$bug->resolvedBuild]) ? $builds[$bug->resolvedBuild] : $bug->resolvedBuild; - } - - return $bugs; - } - /** * Extract accounts from some bugs. * From be1671c243266d705f5b10be90347d577f4a53be Mon Sep 17 00:00:00 2001 From: mayue Date: Thu, 23 Dec 2021 14:34:44 +0800 Subject: [PATCH 2/2] * Modify the code. --- module/bug/control.php | 3 +++ module/bug/model.php | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/module/bug/control.php b/module/bug/control.php index 8afc84a762..bbeb913ca5 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -181,6 +181,9 @@ class bug extends control /* Process bug for check story changed. */ $bugs = $this->loadModel('story')->checkNeedConfirm($bugs); + /* Process the openedBuild and resolvedBuild fields. */ + $bugs = $this->bug->processBuildForBugs($bugs); + /* Get story and task id list. */ $storyIdList = $taskIdList = array(); foreach($bugs as $bug) diff --git a/module/bug/model.php b/module/bug/model.php index 3d7fa64eda..f1518ab47e 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1375,6 +1375,35 @@ class bugModel extends model $this->loadModel('search')->setSearchParams($this->config->bug->search); } + /** + * Process the openedBuild and resolvedBuild fields for bugs. + * + * @param array $bugs + * @access public + * @return array + */ + public function processBuildForBugs($bugs) + { + $productIdList = array(); + foreach($bugs as $bug) $productIdList[$bug->id] = $bug->product; + $builds = $this->loadModel('build')->getBuildPairs(array_unique($productIdList), 'all', $params = ''); + + /* Process the openedBuild and resolvedBuild fields. */ + foreach($bugs as $key => $bug) + { + $openBuildIdList = explode(',', $bug->openedBuild); + $openedBuild = ''; + foreach($openBuildIdList as $buildID) + { + $openedBuild .= isset($builds[$buildID]) ? $builds[$buildID] : $buildID; + $openedBuild .= ','; + } + $bug->openedBuild = rtrim($openedBuild, ','); + $bug->resolvedBuild = isset($builds[$bug->resolvedBuild]) ? $builds[$bug->resolvedBuild] : $bug->resolvedBuild; + } + return $bugs; + } + /** * Extract accounts from some bugs. *