From 67f94f00063513bf4dd72bd59810eb0b4e7b3880 Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Tue, 9 May 2023 10:41:30 +0000 Subject: [PATCH] * Fix sonar. --- module/bug/control.php | 15 ++++++++++----- module/bug/model.php | 10 +++++----- module/bug/tao.php | 1 - module/bug/zen.php | 7 ++----- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index cdce8748ec..ec43b6e7f3 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -587,7 +587,8 @@ class bug extends control $showFields = trim($showFields, ','); } - $projectID = $this->lang->navGroup->bug == 'project' ? $this->session->project : (isset($execution) ? $execution->project : 0); + $projectID = isset($execution) ? $execution->project : 0; + $projectID = $this->lang->navGroup->bug == 'project' ? $this->session->project : $projectID; $project = $this->loadModel('project')->getByID($projectID); if(isset($project->model) && $project->model == 'kanban') $customFields['execution'] = $this->lang->bug->kanban; @@ -847,7 +848,8 @@ class bug extends control if(!isset($modules[$bug->product][$bug->branch]) and isset($modules[$bug->product])) $modules[$bug->product][$bug->branch] = $modules[$bug->product][0] + $this->tree->getModulesName($bug->module); $bugProduct = isset($productList) ? $productList[$bug->product] : $product; - $branch = $bugProduct->type == 'branch' ? ($bug->branch > 0 ? $bug->branch . ',0' : '0') : ''; + $branch = $bug->branch > 0 ? $bug->branch . ',0' : '0'; + $branch = $bugProduct->type == 'branch' ? $branch : ''; if(!isset($productBugList[$bug->product][$bug->branch])) $productBugList[$bug->product][$bug->branch] = $this->bug->getProductBugPairs($bug->product, $branch); } @@ -1475,7 +1477,7 @@ class bug extends control $this->bug->afterClose($bug, $oldBug); $this->executeHooks($bugID); - $this->bug->handleOnlyBodyAfterClose($oldBug->execution, $extra); + $this->bug->handleOnlyBodyAfterClose($oldBug->execution, $extra, $from); if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success', 'data' => $bugID)); @@ -1879,7 +1881,9 @@ class bug extends control { $bug = $this->dao->select('*')->from(TABLE_BUG)->where('id')->eq($bugID)->fetch(); $realname = $this->dao->select('*')->from(TABLE_USER)->where('account')->eq($bug->assignedTo)->fetch('realname'); - $bug->assignedTo = $realname ? $realname : ($bug->assignedTo == 'closed' ? 'Closed' : $bug->assignedTo); + + $bug->assignedTo = $bug->assignedTo == 'closed' ? 'Closed' : $bug->assignedTo; + $bug->assignedTo = $realname ?: $bug->assignedTo; return print(json_encode($bug)); } @@ -1963,7 +1967,8 @@ class bug extends control { $product = $this->loadModel('product')->getById($productID); $bug = $this->bug->getById($bugID); - $branch = $product->type == 'branch' ? ($bug->branch > 0 ? $bug->branch . ',0' : '0') : ''; + $branch = $bug->branch > 0 ? $bug->branch . ',0' : '0'; + $branch = $product->type == 'branch' ? $branch : ''; $productBugs = $this->bug->getProductBugPairs($productID, $branch); unset($productBugs[$bugID]); diff --git a/module/bug/model.php b/module/bug/model.php index af2734f34d..5049a7ad6e 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1254,11 +1254,10 @@ class bugModel extends model * Close a bug. * * @param object $bug - * @param string $extra * @access public * @return void */ - public function close(object $bug, string $extra = '') + public function close(object $bug) { $this->dao->update(TABLE_BUG) ->data($bug, 'comment') @@ -1290,12 +1289,13 @@ class bugModel extends model * 处理弹窗关闭bug的情况。 * Handle close bug from only body. * - * @param int $executionId - * @param int $extra + * @param int $executionId + * @param string $extra + * @param string $extra * @access public * @return viod */ - public function handleOnlyBodyAfterClose($executionId, $extra) + public function handleOnlyBodyAfterClose($executionId, $extra, $from) { if(!isonlybody()) return; diff --git a/module/bug/tao.php b/module/bug/tao.php index 3a732da0f3..4a5a5b3a15 100644 --- a/module/bug/tao.php +++ b/module/bug/tao.php @@ -241,7 +241,6 @@ class bugTao extends bugModel { if(in_array($changedBugID, $addedLinkBugs)) { - $currentLinkBug = $bugID; $linkBugs = explode(',', $linkBugs); if(!empty($linkBugs) && !in_array($bugID, $linkBugs)) $linkBugs[] = $bugID; } diff --git a/module/bug/zen.php b/module/bug/zen.php index 963c4201da..4f56f04d37 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -558,7 +558,7 @@ class bugZen extends bug $stories = $this->story->getProductStoryPairs($productID, $branch, $moduleID, 'all','id_desc', 0, 'full', 'story', false); } - return $this->updateBugTemplete($bugTpl, array('stories' => $stories, 'builds' => $builds)); + return $this->updateBugTemplete($bugTpl, array('stories' => $stories, 'builds' => $builds, 'projectID' => $projectID)); } /** @@ -633,10 +633,7 @@ class bugZen extends bug $projectID = $bugTpl->projectID; $project = $bugTpl->project; - if($projectID and $project) - { - if(!$bugID or $this->app->tab != 'qa') $projects += array($projectID => $project->name); - } + if($projectID and $project and (!$bugID or $this->app->tab != 'qa')) $projects += array($projectID => $project->name); /* Link all projects to product when copying bug under qa.*/ if($bugID and $this->app->tab == 'qa') $projects += $this->product->getProjectPairsByProduct($productID, $branch);