From 6802dcbe05427ecadfb55cb802145f6040be5cb6 Mon Sep 17 00:00:00 2001 From: wangxuepeng Date: Wed, 27 Dec 2023 17:11:53 +0800 Subject: [PATCH] * Fix bug #42525, fixed related bugs. --- module/bug/zen.php | 1 + module/testcase/control.php | 2 +- module/testtask/control.php | 12 ++++++++---- module/testtask/zen.php | 23 +++++++++++++++++++++++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/module/bug/zen.php b/module/bug/zen.php index 9c27af81b9..609e0ad05d 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -221,6 +221,7 @@ class bugZen extends bug /* 如果是多分支产品时,设置分支的 cookie。*/ /* Set branch cookie if product is multi-branch. */ helper::setcookie('preBranch', $branch); + $this->session->set('branch', $branch, 'qa'); return $branch; } diff --git a/module/testcase/control.php b/module/testcase/control.php index 40f4a164b5..e5aff28e1a 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -93,7 +93,7 @@ class testcase extends control /* 把访问的产品ID等状态信息保存到session和cookie中。*/ /* Save the product id user last visited to session and cookie. */ $productID = $this->app->tab != 'project' ? $this->product->checkAccess($productID, $this->products) : $productID; - $branch = $this->cookie->preBranch && $this->cookie->preBranch !== '' && $branch === '' ? $this->cookie->preBranch : $branch; + $branch = ($this->cookie->preBranch || $this->cookie->preBranch === '0') && $this->cookie->preBranch !== '' && $branch === '' ? $this->cookie->preBranch : $branch; $browseType = strtolower($browseType); $moduleID = $browseType == 'bymodule' ? $param : 0; $suiteID = $browseType == 'bysuite' ? $param : ($browseType == 'bymodule' ? ($this->cookie->caseSuite ? $this->cookie->caseSuite : 0) : 0); diff --git a/module/testtask/control.php b/module/testtask/control.php index 789b750740..0d34dc5c76 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -89,9 +89,6 @@ class testtask extends control $this->session->set('testtaskList', $uri, 'qa'); $this->session->set('reportList', $uri, 'qa'); $this->session->set('buildList', $uri, 'execution'); - $this->session->set('branch', $branch, 'qa'); - - $this->loadModel('qa')->setMenu($productID, $branch); /* 预处理部分变量供查询使用。*/ /* Prepare variables for query. */ @@ -101,7 +98,14 @@ class testtask extends control $endTime = $endTime ? date('Y-m-d', strtotime($endTime)) : ''; $sort = common::appendOrder($orderBy); $product = $this->product->getById($productID); - if($product->type == 'normal') $branch = 'all'; + + /* 处理分支。 */ + /* Process branch. */ + $branch = $this->testtaskZen->getBrowseBranch($branch, $product->type); + + /* 设置1.5级菜单。 */ + /* Set 1.5 level menu. */ + $this->loadModel('qa')->setMenu($productID, $branch); /* 从数据库中查询符合条件的测试单。*/ /* Query the testtasks from the database. */ diff --git a/module/testtask/zen.php b/module/testtask/zen.php index f984f3f4b6..60d1ef47f7 100644 --- a/module/testtask/zen.php +++ b/module/testtask/zen.php @@ -28,6 +28,29 @@ class testtaskZen extends testtask return $this->loadModel('qa')->setMenu($productID, $branch); } + /** + * 获取列表页面的 branch 参数。 + * Get browse branch param. + * + * @param string $branch + * @param string $productType + * @access protected + * @return string + */ + protected function getBrowseBranch(string $branch, string $productType): string + { + if($productType == 'normal') return 'all'; + + if($this->cookie->preBranch !== '' && $branch === '') $branch = (string)$this->cookie->preBranch; + + /* 如果是多分支产品时,设置分支的 cookie。*/ + /* Set branch cookie if product is multi-branch. */ + helper::setcookie('preBranch', $branch); + $this->session->set('branch', $branch, 'qa'); + + return $branch; + } + /** * 设置测试单用例列表页面搜索表单的参数。 * Set congiruration of search form in cases page of testtask.