From d15618bbb9b7cbfe2e147d2143c24c27858f1732 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 12 Feb 2025 11:24:16 +0800 Subject: [PATCH] * [misc,done,0.1h] optimize code. --- module/bug/zen.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/module/bug/zen.php b/module/bug/zen.php index 872e47c573..16eafd0609 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -1213,6 +1213,13 @@ class bugZen extends bug */ protected function assignVarsForEdit(object $bug): void { + /* Add product related to the bug when it is not in the products. */ + if(!isset($this->products[$bug->product])) + { + $this->products[$bug->product] = $product->name; + $this->view->products = $this->products; + } + $product = $this->loadModel('product')->fetchByID($bug->product); if(empty($product->shadow)) { @@ -1220,18 +1227,11 @@ class bugZen extends bug $productList = $this->loadModel('product')->getByIdList(array_keys($products)); foreach($products as $id => $name) { - if(!empty($productList[$id]->shadow) || $productList[$id]->status == 'closed') unset($products[$id]); + if($id != $bug->product && (!empty($productList[$id]->shadow) || $productList[$id]->status == 'closed')) unset($products[$id]); } $this->view->products = $products; } - /* Add product related to the bug when it is not in the products. */ - if(!isset($this->products[$bug->product])) - { - $this->products[$bug->product] = $product->name; - $this->view->products = $this->products; - } - if($bug->execution) { $openedBuilds = $this->loadModel('build')->getBuildPairs(array($bug->product), $bug->branch, 'noempty,noterminate,nodone,withbranch,noreleased,nofail', $bug->execution, 'execution');