From e486908d525ddea006da11534148bc3f941769e2 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Thu, 27 Apr 2023 13:58:26 +0800 Subject: [PATCH] * Fix bug #34886. --- module/testcase/control.php | 2 +- module/testcase/model.php | 51 ++++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/module/testcase/control.php b/module/testcase/control.php index 8032bebdde..10e6c7bcb9 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -176,7 +176,7 @@ class testcase extends control } /* save session .*/ - $this->loadModel('common')->saveQueryCondition($this->testcase->dao->get(), 'testcase', false); + $this->loadModel('common')->saveQueryCondition($queryCondition, 'testcase', false); /* Get summary. */ $indCount = 0; diff --git a/module/testcase/model.php b/module/testcase/model.php index 8e76a0a221..dcde0fe608 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -3500,30 +3500,39 @@ class testcaseModel extends model foreach(explode(',', trim($path, ',')) as $pathID) $objectIdList[$pathID] = $pathID; } - /* Get paginated data with all IDs list. */ - $queryFunction = function($modules, $type, $objectIdList, $branch) - { - $this->dao->reset(); - $rawMethod = $this->app->rawMethod; - $rawModule = $this->app->rawModule; - return $this->dao->select('*')->from(VIEW_SCENECASE) - ->where('deleted')->eq(0) - ->beginIF($this->cookie->onlyScene)->andWhere('isCase')->eq(2)->fi() - ->beginIF($modules)->andWhere('module')->in($modules)->fi() - ->beginIF($rawMethod == 'browse' and $type === 'top')->andWhere('parent')->eq(0)->andWhere('id')->in($objectIdList)->fi() - ->beginIF($rawMethod == 'browse' and $type === 'child')->andWhere('id')->in($objectIdList)->fi() - ->beginIF($rawModule == 'project' and $rawMethod == 'testcase' and intval($branch) > 0)->andWhere('branch')->eq($branch)->fi() - ->beginIF($rawModule == 'project' and $rawMethod == 'testcase' and $type === 'top')->andWhere('parent')->eq(0)->andWhere('id')->in($objectIdList)->fi() - ->beginIF($rawModule == 'project' and $rawMethod == 'testcase' and $type === 'child')->andWhere('id')->in($objectIdList)->fi(); - }; - /* Sort by product ID for project list. */ $orderBy = 'product_desc,sort_asc'; /* Get sql for batch execution. */ - if($executionSql !== NULL) $executionSql = $queryFunction($modules, $type, $objectIdList, $branch)->andWhere('isCase')->eq(1)->orderBy($orderBy)->get(); + if($executionSql !== NULL) $executionSql = $this->buildQuery($modules, $type, $objectIdList, $branch)->andWhere('isCase')->eq(1)->orderBy($orderBy)->get(); - return $queryFunction($modules, $type, $objectIdList, $branch)->orderBy($orderBy)->page($pager)->fetchAll('id'); + return $this->buildQuery($modules, $type, $objectIdList, $branch)->orderBy($orderBy)->page($pager)->fetchAll('id'); + } + + /** + * Get paginated data with all IDs list. + * + * @param string $modules + * @param string $type + * @param string $objectIdList + * @param string $branch + * @access public + * @return object + */ + private function buildQuery($modules, $type, $objectIdList, $branch) + { + $this->dao->reset(); + $rawMethod = $this->app->rawMethod; + $rawModule = $this->app->rawModule; + return $this->dao->select('*')->from(VIEW_SCENECASE) + ->where('deleted')->eq(0) + ->beginIF($this->cookie->onlyScene)->andWhere('isCase')->eq(2)->fi() + ->beginIF($modules)->andWhere('module')->in($modules)->fi() + ->beginIF($rawMethod == 'browse' and $type === 'top')->andWhere('parent')->eq(0)->andWhere('id')->in($objectIdList)->fi() + ->beginIF($rawMethod == 'browse' and $type === 'child')->andWhere('id')->in($objectIdList)->fi() + ->beginIF($rawModule == 'project' and $rawMethod == 'testcase' and intval($branch) > 0)->andWhere('branch')->eq($branch)->fi() + ->beginIF($rawModule == 'project' and $rawMethod == 'testcase' and $type === 'top')->andWhere('parent')->eq(0)->andWhere('id')->in($objectIdList)->fi() + ->beginIF($rawModule == 'project' and $rawMethod == 'testcase' and $type === 'child')->andWhere('id')->in($objectIdList)->fi(); } /** @@ -3607,7 +3616,7 @@ class testcaseModel extends model foreach($scenes as $scene) { - $branchName = (isset($product) and $product->type != 'normal' and $scene->branch === BRANCH_MAIN) ? $this->lang->branch->main : $branch; + $branchName = (!empty($product) and $product->type != 'normal' and $scene->branch === BRANCH_MAIN) ? $this->lang->branch->main : $branch; $this->buildTreeArray($treeMenu, $scenes, $scene, (empty($branchName)) ? '/' : "/$branchName/"); } @@ -4577,7 +4586,7 @@ class testcaseModel extends model else { // Key exists so convert to integer indexed array with previous value in position 0 - $tagsArray[$childTagName] = [$tagsArray[$childTagName], $childProperties]; + $tagsArray[$childTagName] = array($tagsArray[$childTagName], $childProperties); } } }