From be1671c243266d705f5b10be90347d577f4a53be Mon Sep 17 00:00:00 2001 From: mayue Date: Thu, 23 Dec 2021 14:34:44 +0800 Subject: [PATCH] * 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. *