From f7bdd4283d3a0368b39b6ee4e9a6b220affcc9a3 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 7 Aug 2025 15:19:49 +0800 Subject: [PATCH 01/32] + [perf] Add a method to cache search parameters. --- framework/model.class.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/framework/model.class.php b/framework/model.class.php index 0bcbd659ce..ca902f2ac8 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -282,6 +282,40 @@ class model extends baseModel return $menu; } + /** + * 缓存基础搜索参数。 + * Cache basic search params. + * + * @param string $module + * @param string $className 构造搜索参数的类名。The class name which builds the search params. + * @param string $methodName 构造搜索参数的方法名。The method name which builds the search params. + * @param array $methodArgs 调用构造搜索参数的方法时传入的参数列表(实参)。 The arguments passed to the method which builds the search params (actual parameters). + * @access public + * @return void + */ + public function cacheSearchParams(string $module, string $className, string $methodName, array $methodArgs) + { + $funcModel = str_replace(['ext', 'Model'], '', $className); + + $key = 0; + $funcArgs = []; + $method = new ReflectionMethod($className, $methodName); + $params = $method->getParameters(); // 构造搜索参数的方法的参数列表(形参)。The parameters of the method which builds the search params (formal parameters). + foreach($params as $param) + { + if(isset($methodArgs[$key])) + { + $funcArgs[$param->getName()] = $methodArgs[$key]; + } + elseif($param->isDefaultValueAvailable()) + { + $funcArgs[$param->getName()] = $param->getDefaultValue(); + } + $key++; + } + $this->loadModel('search')->setSearchParams(['module' => $module, 'funcModel' => $funcModel, 'funcName' => $methodName, 'funcArgs' => $funcArgs]); + } + /** * Process status of an object according to its subStatus. * From 4cdff092dd6d97cddccf67d5f54e2f0cf3801007 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 7 Aug 2025 15:34:25 +0800 Subject: [PATCH 02/32] * [perf] Clear old search params and support function-based parameter storage. --- module/search/model.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/search/model.php b/module/search/model.php index 796032ccb0..07375c4724 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -22,10 +22,13 @@ class searchModel extends model * @access public * @return void */ - public function setSearchParams(array $searchConfig): void + public function setSearchParams(array $searchConfig) { $module = $searchConfig['module']; + $this->session->set($module . 'searchParams', null); // 清除旧的搜索参数。Clear old search params. + if(!empty($searchConfig['funcModel']) && !empty($searchConfig['funcName'])) return $this->session->set($module . 'searchParams', $searchConfig); + if($this->config->edition != 'open') $searchConfig = $this->searchTao->processBuildinFields($module, $searchConfig); $searchParams['module'] = $searchConfig['module']; From b15b8d99957f8ba4ab3548e9c1048279bbb35fc2 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 7 Aug 2025 15:37:43 +0800 Subject: [PATCH 03/32] + [perf] Add a method to process search parameters when needed. --- module/search/zen.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/module/search/zen.php b/module/search/zen.php index aa0746e518..2c887830cd 100644 --- a/module/search/zen.php +++ b/module/search/zen.php @@ -2,6 +2,25 @@ declare(strict_types=1); class searchZen extends search { + /** + * 构造搜索表单时调用被搜索模块的方法处理搜索参数。 + * Call the method of the searched module to process search parameters when constructing the search form. + * + * @param string $searchParams + * @access public + * @return bool + */ + public function processSearchParams(string $searchParams): bool + { + $funcModel = $_SESSION[$searchParams]['funcModel'] ?? ''; + $funcName = $_SESSION[$searchParams]['funcName'] ?? ''; + $funcArgs = $_SESSION[$searchParams]['funcArgs'] ?? []; + if(!$funcModel || !$funcName) return false; + + $funcArgs['processParams'] = true; // 添加处理搜索参数的标记。Add a flag to process search parameters. + $this->loadModel($funcModel)->$funcName(...$funcArgs); + return true; + } /** * 设置列表 session,方便返回。 * Set list in session, for come back search index page. From e50e1ef83419ebe1e6ef87c8c24d18e2c43e50e4 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 7 Aug 2025 15:38:34 +0800 Subject: [PATCH 04/32] + [perf] Optimize search module to process search parameters when needed. --- module/search/control.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/module/search/control.php b/module/search/control.php index d52d3d9feb..1b069337a6 100644 --- a/module/search/control.php +++ b/module/search/control.php @@ -35,6 +35,8 @@ class search extends control $searchParams = $module . 'searchParams'; $searchForm = $module . 'Form'; + $this->searchZen->processSearchParams($searchParams); + $fields = empty($fields) ? json_decode($_SESSION[$searchParams]['searchFields'], true) : $fields; $params = empty($params) ? json_decode($_SESSION[$searchParams]['fieldParams'], true) : $params; @@ -83,6 +85,8 @@ class search extends control $searchParams = $module . 'searchParams'; $searchForm = $module . 'Form'; + $this->searchZen->processSearchParams($searchParams); + $fields = empty($fields) ? json_decode($_SESSION[$searchParams]['searchFields'], true) : $fields; $params = empty($params) ? json_decode($_SESSION[$searchParams]['fieldParams'], true) : $params; From 2a06c19ab3a45d596ba885cbc5b0f7f3990f7f19 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 7 Aug 2025 15:40:06 +0800 Subject: [PATCH 05/32] * [perf] Implement lazy search parameter processing in executionModel::buildTaskSearchForm(). --- module/execution/model.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module/execution/model.php b/module/execution/model.php index 472adc91ef..cbd2d61e8a 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4172,11 +4172,15 @@ class executionModel extends model * @param array $executions * @param int $queryID * @param string $actionURL + * @param bool $processParams 是否处理搜索参数。默认不处理可以提高性能,构造搜索表单时再处理。 * @access public * @return void */ - public function buildTaskSearchForm(int $executionID, array $executions, int $queryID, string $actionURL) + public function buildTaskSearchForm(int $executionID, array $executions, int $queryID, string $actionURL, bool $processParams = false) { + $module = $this->config->execution->search['module']; + if(!$processParams) return $this->cacheSearchParams($module, __CLASS__, __FUNCTION__, func_get_args()); + $showAll = empty($executionID) && empty($executions) ? true : false; if($showAll) { From 145aa104ff33c6bc00d18bb88d594ae12f222cda Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 7 Aug 2025 15:41:12 +0800 Subject: [PATCH 06/32] * [perf] Implement lazy search parameter processing in myModel::buildTaskSearchForm(). --- module/my/control.php | 2 +- module/my/model.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/module/my/control.php b/module/my/control.php index a3de5067b3..ee7173a6c9 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -434,7 +434,7 @@ class my extends control $tasks = $this->myZen->buildTaskData($tasks); $actionURL = $this->createLink('my', $this->app->rawMethod, "mode=task&browseType=bySearch&queryID=myQueryID"); - $this->my->buildTaskSearchForm($queryID, $actionURL); + $this->my->buildTaskSearchForm($queryID, $actionURL, $this->app->rawMethod); $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID); diff --git a/module/my/model.php b/module/my/model.php index 59eb4c82f1..36bb9f9102 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -448,15 +448,19 @@ class myModel extends model * * @param int $queryID * @param string $actionURL + * @param string $rawMethod + * @param bool $processParams 是否处理搜索参数。默认不处理可以提高性能,构造搜索表单时再处理。 * @access public * @return void */ - public function buildTaskSearchForm(int $queryID, string $actionURL): void + public function buildTaskSearchForm(int $queryID, string $actionURL, string $rawMethod, bool $processParams = false) { - $rawMethod = $this->app->rawMethod; + $module = $rawMethod . 'Task'; + if(!$processParams) return $this->cacheSearchParams($module, __CLASS__, __FUNCTION__, func_get_args()); + $this->loadModel('execution'); - $this->config->execution->search['module'] = $rawMethod . 'Task'; + $this->config->execution->search['module'] = $module; $this->config->execution->search['actionURL'] = $actionURL; $this->config->execution->search['queryID'] = $queryID; From eb560031598aec8aeeb3c9ac82879351887a9615 Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 8 Aug 2025 11:38:52 +0800 Subject: [PATCH 07/32] * [perf] Replace the magic constants __CLASS__ and __FUNCTION__ with the magic constant __METHOD__ to simplify the code. --- framework/model.class.php | 9 +++++---- module/execution/model.php | 2 +- module/my/model.php | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/framework/model.class.php b/framework/model.class.php index ca902f2ac8..0ed7134191 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -287,14 +287,15 @@ class model extends baseModel * Cache basic search params. * * @param string $module - * @param string $className 构造搜索参数的类名。The class name which builds the search params. - * @param string $methodName 构造搜索参数的方法名。The method name which builds the search params. - * @param array $methodArgs 调用构造搜索参数的方法时传入的参数列表(实参)。 The arguments passed to the method which builds the search params (actual parameters). + * @param string $classMethod 构造搜索参数的类名和方法名,以::分隔。The class name and method name which builds the search params, separated by ::. + * @param array $methodArgs 调用构造搜索参数的方法时传入的参数列表(实参)。 The arguments passed to the method which builds the search params (actual parameters). * @access public * @return void */ - public function cacheSearchParams(string $module, string $className, string $methodName, array $methodArgs) + public function cacheSearchParams(string $module, string $classMethod, array $methodArgs) { + list($className, $methodName) = explode('::', $classMethod); + $funcModel = str_replace(['ext', 'Model'], '', $className); $key = 0; diff --git a/module/execution/model.php b/module/execution/model.php index cbd2d61e8a..45c87f8d47 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4179,7 +4179,7 @@ class executionModel extends model public function buildTaskSearchForm(int $executionID, array $executions, int $queryID, string $actionURL, bool $processParams = false) { $module = $this->config->execution->search['module']; - if(!$processParams) return $this->cacheSearchParams($module, __CLASS__, __FUNCTION__, func_get_args()); + if(!$processParams) return $this->cacheSearchParams($module, __METHOD__, func_get_args()); $showAll = empty($executionID) && empty($executions) ? true : false; if($showAll) diff --git a/module/my/model.php b/module/my/model.php index 36bb9f9102..cf713548ec 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -456,7 +456,7 @@ class myModel extends model public function buildTaskSearchForm(int $queryID, string $actionURL, string $rawMethod, bool $processParams = false) { $module = $rawMethod . 'Task'; - if(!$processParams) return $this->cacheSearchParams($module, __CLASS__, __FUNCTION__, func_get_args()); + if(!$processParams) return $this->cacheSearchParams($module, __METHOD__, func_get_args()); $this->loadModel('execution'); From a2227c2e0d4a796a23ea8ad47784ce5aeba4ad88 Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 8 Aug 2025 11:49:16 +0800 Subject: [PATCH 08/32] * [perf] Rename the processParams parameter to cacheSearchParams. --- module/execution/model.php | 6 +++--- module/my/model.php | 6 +++--- module/search/zen.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index 45c87f8d47..bacef5a9f3 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4172,14 +4172,14 @@ class executionModel extends model * @param array $executions * @param int $queryID * @param string $actionURL - * @param bool $processParams 是否处理搜索参数。默认不处理可以提高性能,构造搜索表单时再处理。 + * @param bool $cacheSearchParams 是否缓存搜索参数。默认缓存可以提高性能,构造搜索表单时再加载真实值。 * @access public * @return void */ - public function buildTaskSearchForm(int $executionID, array $executions, int $queryID, string $actionURL, bool $processParams = false) + public function buildTaskSearchForm(int $executionID, array $executions, int $queryID, string $actionURL, bool $cacheSearchParams = true) { $module = $this->config->execution->search['module']; - if(!$processParams) return $this->cacheSearchParams($module, __METHOD__, func_get_args()); + if($cacheSearchParams) return $this->cacheSearchParams($module, __METHOD__, func_get_args()); $showAll = empty($executionID) && empty($executions) ? true : false; if($showAll) diff --git a/module/my/model.php b/module/my/model.php index cf713548ec..3d8350877b 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -449,14 +449,14 @@ class myModel extends model * @param int $queryID * @param string $actionURL * @param string $rawMethod - * @param bool $processParams 是否处理搜索参数。默认不处理可以提高性能,构造搜索表单时再处理。 + * @param bool $cacheSearchParams 是否缓存搜索参数。默认缓存可以提高性能,构造搜索表单时再加载真实值。 * @access public * @return void */ - public function buildTaskSearchForm(int $queryID, string $actionURL, string $rawMethod, bool $processParams = false) + public function buildTaskSearchForm(int $queryID, string $actionURL, string $rawMethod, bool $cacheSearchParams = true) { $module = $rawMethod . 'Task'; - if(!$processParams) return $this->cacheSearchParams($module, __METHOD__, func_get_args()); + if($cacheSearchParams) return $this->cacheSearchParams($module, __METHOD__, func_get_args()); $this->loadModel('execution'); diff --git a/module/search/zen.php b/module/search/zen.php index 2c887830cd..fd99cdd137 100644 --- a/module/search/zen.php +++ b/module/search/zen.php @@ -17,7 +17,7 @@ class searchZen extends search $funcArgs = $_SESSION[$searchParams]['funcArgs'] ?? []; if(!$funcModel || !$funcName) return false; - $funcArgs['processParams'] = true; // 添加处理搜索参数的标记。Add a flag to process search parameters. + $funcArgs['cacheSearchParams'] = false; // 不缓存搜索参数以加载真实值。Do not cache search parameters to load real values. $this->loadModel($funcModel)->$funcName(...$funcArgs); return true; } From ab4ecfb7af89b79f4648b95ff13380475fc06492 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 11 Aug 2025 10:16:20 +0800 Subject: [PATCH 09/32] * [perf] refactor: enhance task search form building functionality - Add productID parameter to buildTaskSearchForm method to support better filtering - Introduce module parameter to handle different search contexts (task, programplanTask, projectTask) - Refactor search configuration to be more modular and context-aware - Remove hardcoded search module configurations and pass them as parameters - Simplify search form initialization across execution, programplan, and project modules - Improve code reusability by centralizing search configuration logic - Add conditional field filtering based on execution type and search context --- module/execution/control.php | 4 +-- module/execution/model.php | 55 +++++++++++++++++++++++++++--------- module/programplan/zen.php | 6 +--- module/project/control.php | 9 ++---- 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 7912807501..34d806dbc3 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -197,9 +197,7 @@ class execution extends control /* Build the search form. */ $modules = $this->loadModel('tree')->getTaskOptionMenu($executionID, 0, $showModule); $actionURL = $this->createLink('execution', 'task', "executionID=$executionID&status=bySearch¶m=myQueryID&orderBy=$orderBy&recTotal=0&recPerPage=100&pageID=1&from=$from&blockID=$blockID"); - $this->config->execution->search['onMenuBar'] = 'yes'; - if(!$execution->multiple) unset($this->config->execution->search['fields']['execution']); - $this->execution->buildTaskSearchForm($executionID, $this->executions, $queryID, $actionURL); + $this->execution->buildTaskSearchForm($executionID, $productID, $this->executions, $queryID, $actionURL); $this->view->title = $execution->name . $this->lang->hyphen . $this->lang->execution->task; $this->view->tasks = $tasks; diff --git a/module/execution/model.php b/module/execution/model.php index bacef5a9f3..f8d9e2f2d3 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4169,6 +4169,7 @@ class executionModel extends model * Build task search form. * * @param int $executionID + * @param int $productID * @param array $executions * @param int $queryID * @param string $actionURL @@ -4176,12 +4177,16 @@ class executionModel extends model * @access public * @return void */ - public function buildTaskSearchForm(int $executionID, array $executions, int $queryID, string $actionURL, bool $cacheSearchParams = true) + public function buildTaskSearchForm(int $executionID, int $productID, array $executions, int $queryID, string $actionURL, string $module = 'task', bool $cacheSearchParams = true) { - $module = $this->config->execution->search['module']; if($cacheSearchParams) return $this->cacheSearchParams($module, __METHOD__, func_get_args()); - $showAll = empty($executionID) && empty($executions) ? true : false; + $searchConfig = $this->config->execution->search; + $searchConfig['module'] = $module; + $searchConfig['actionURL'] = $actionURL; + $searchConfig['queryID'] = $queryID; + + $showAll = empty($executionID) && empty($executions); if($showAll) { $executions = $this->getPairs(0, 'all', "nocode,noprefix,multiple"); @@ -4189,27 +4194,49 @@ class executionModel extends model } $execution = $this->getByID($executionID); - $this->config->execution->search['actionURL'] = $actionURL; - $this->config->execution->search['queryID'] = $queryID; - $this->config->execution->search['params']['story']['values'] = $this->loadModel('story')->getExecutionStoryPairs($executionID, 0, 'all', '', 'full', 'unclosed', 'story', false); + $searchConfig['params']['story']['values'] = $this->loadModel('story')->getExecutionStoryPairs($executionID, 0, 'all', '', 'full', 'unclosed', 'story', false); + + if($module == 'task') + { + $searchConfig['onMenuBar'] = 'yes'; + if(!$execution->multiple) unset($searchConfig['fields']['execution']); + } + elseif($module == 'programplanTask') + { + unset($searchConfig['fields']['project']); + $executions = $this->loadModel('programplan')->getPairs($projectID, $productID, 'all'); + } + elseif($module == 'projectTask') + { + unset($searchConfig['fields']['project']); + unset($searchConfig['fields']['module']); + } if(isset($execution->type) && $execution->type == 'project') { - unset($this->config->execution->search['fields']['project']); - $this->config->execution->search['params']['execution']['values'] = array('' => '') + $executions; + unset($searchConfig['fields']['project']); + if(isset($searchConfig['fields']['execution'])) $searchConfig['params']['execution']['values'] = array('' => '') + $executions; } else { - $this->config->execution->search['params']['execution']['values'] = $showAll ? $executions : array(''=>'', $executionID => zget($executions, $executionID, ''), 'all' => $this->lang->execution->allExecutions); + if(isset($searchConfig['fields']['execution'])) $searchConfig['params']['execution']['values'] = $showAll ? $executions : array(''=>'', $executionID => zget($executions, $executionID, ''), 'all' => $this->lang->execution->allExecutions); } - $projects = $this->loadModel('project')->getPairsByProgram(); - $this->config->execution->search['params']['project']['values'] = $projects + array('all' => $this->lang->project->allProjects); + if(isset($searchConfig['fields']['project'])) + { + $projects = $this->loadModel('project')->getPairsByProgram(); + $searchConfig['params']['project']['values'] = $projects + array('all' => $this->lang->project->allProjects); + } - $showAllModule = isset($this->config->execution->task->allModule) ? $this->config->execution->task->allModule : ''; - $this->config->execution->search['params']['module']['values'] = $this->loadModel('tree')->getTaskOptionMenu($executionID, 0, $showAllModule ? 'allModule' : ''); + if(isset($searchConfig['fields']['module'])) + { + $showAllModule = $this->config->execution->task->allModule ?? ''; + $searchConfig['params']['module']['values'] = $this->loadModel('tree')->getTaskOptionMenu($executionID, 0, $showAllModule ? 'allModule' : ''); + } - $this->loadModel('search')->setSearchParams($this->config->execution->search); + $this->loadModel('search')->setSearchParams($searchConfig); + + return $searchConfig; } /** diff --git a/module/programplan/zen.php b/module/programplan/zen.php index 169c9ede7e..4cbcc25434 100644 --- a/module/programplan/zen.php +++ b/module/programplan/zen.php @@ -441,12 +441,8 @@ class programplanZen extends programplan if($hasSearch) { /* Build the search form. */ - $this->config->execution->search['module'] = 'projectTask'; - $actionURL = $this->createLink('programplan', 'browse', "projectID=$projectID&productID=$productID&type=$type&orderBy=$orderBy&baselineID=$baselineID&browseType=bysearch&queryID=myQueryID"); - unset($this->config->execution->search['fields']['project']); - $executions = $this->programplan->getPairs($projectID, $productID, 'all'); - $this->loadModel('execution')->buildTaskSearchForm($projectID, $executions, $queryID, $actionURL); + $this->loadModel('execution')->buildTaskSearchForm($projectID, $productID, $executions, $queryID, $actionURL, 'programplanTask'); } $this->view->title = $this->lang->programplan->browse; diff --git a/module/project/control.php b/module/project/control.php index 90812f98c2..aef9423d06 100755 --- a/module/project/control.php +++ b/module/project/control.php @@ -870,15 +870,10 @@ class project extends control if($this->cookie->showTask) { /* Build the search form. */ - $this->config->execution->search['module'] = 'projectTask'; - - $actionURL = $this->createLink('project', 'execution', "status=bysearch&projectID=$projectID&orderBy=$orderBy&productID=$productID&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID&queryID=myQueryID"); - unset($this->config->execution->search['fields']['project']); - unset($this->config->execution->search['fields']['module']); + $actionURL = $this->createLink('project', 'execution', "status=bysearch&projectID=$projectID&orderBy=$orderBy&productID=$productID&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID&queryID=myQueryID"); $executions = $this->execution->fetchExecutionList($projectID, 'all', $productID); $executions = $this->execution->getPairsByList(array_keys($executions)); - - $this->execution->buildTaskSearchForm($projectID, $executions, $queryID, $actionURL); + $this->execution->buildTaskSearchForm($projectID, $productID, $executions, $queryID, $actionURL, 'projectTask'); } $this->view->title = $this->lang->execution->allExecutions; From 44828b6deedf5dff229bf079814e8e7027ac21f4 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 11 Aug 2025 14:38:56 +0800 Subject: [PATCH 10/32] * [perf] refactor: improve task search configuration handling in my module - Replace direct modification of global config with local searchConfig variable - Avoid side effects by working with local copy instead of modifying shared config - Add return statement to provide searchConfig for potential future use --- module/my/model.php | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/module/my/model.php b/module/my/model.php index 3d8350877b..86334685dc 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -460,30 +460,33 @@ class myModel extends model $this->loadModel('execution'); - $this->config->execution->search['module'] = $module; - $this->config->execution->search['actionURL'] = $actionURL; - $this->config->execution->search['queryID'] = $queryID; + $searchConfig = $this->config->execution->search; + $searchConfig['module'] = $module; + $searchConfig['actionURL'] = $actionURL; + $searchConfig['queryID'] = $queryID; if($rawMethod == 'work') { - unset($this->config->execution->search['fields']['closedReason']); - unset($this->config->execution->search['fields']['closedBy']); - unset($this->config->execution->search['fields']['canceledBy']); - unset($this->config->execution->search['fields']['closedDate']); - unset($this->config->execution->search['fields']['canceledDate']); - unset($this->config->execution->search['params']['status']['values']['cancel']); - unset($this->config->execution->search['params']['status']['values']['closed']); + unset($searchConfig['fields']['closedReason']); + unset($searchConfig['fields']['closedBy']); + unset($searchConfig['fields']['canceledBy']); + unset($searchConfig['fields']['closedDate']); + unset($searchConfig['fields']['canceledDate']); + unset($searchConfig['params']['status']['values']['cancel']); + unset($searchConfig['params']['status']['values']['closed']); } $projects = $this->loadModel('project')->getPairsByProgram(); - $this->config->execution->search['params']['project']['values'] = $projects + array('all' => $this->lang->project->allProjects); + $searchConfig['params']['project']['values'] = $projects + array('all' => $this->lang->project->allProjects); $executions = $this->execution->getPairs(0, 'all', 'multiple'); - $this->config->execution->search['params']['execution']['values'] = $executions + array('all' => $this->lang->execution->allExecutions); + $searchConfig['params']['execution']['values'] = $executions + array('all' => $this->lang->execution->allExecutions); - $this->config->execution->search['params']['module']['values'] = $this->loadModel('tree')->getAllModulePairs(); + $searchConfig['params']['module']['values'] = $this->loadModel('tree')->getAllModulePairs(); - $this->loadModel('search')->setSearchParams($this->config->execution->search); + $this->loadModel('search')->setSearchParams($searchConfig); + + return $searchConfig; } /** From 993931eb0dbea63d28aca058d34b543d44a3f548 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 11 Aug 2025 14:53:00 +0800 Subject: [PATCH 11/32] * [perf] refactor: optimize search parameter handling mechanism - Replace loadModel('search')->setSearchParams() call with direct session setting in framework/model.class.php - Remove redundant parameter clearing and early return logic from searchModel::setSearchParams method --- framework/model.class.php | 3 ++- module/search/model.php | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/framework/model.class.php b/framework/model.class.php index 0ed7134191..39e9cafd96 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -314,7 +314,8 @@ class model extends baseModel } $key++; } - $this->loadModel('search')->setSearchParams(['module' => $module, 'funcModel' => $funcModel, 'funcName' => $methodName, 'funcArgs' => $funcArgs]); + + $this->session->set($module . 'searchParams', ['funcModel' => $funcModel, 'funcName' => $methodName, 'funcArgs' => $funcArgs]); } /** diff --git a/module/search/model.php b/module/search/model.php index 07375c4724..5d40873849 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -26,9 +26,6 @@ class searchModel extends model { $module = $searchConfig['module']; - $this->session->set($module . 'searchParams', null); // 清除旧的搜索参数。Clear old search params. - if(!empty($searchConfig['funcModel']) && !empty($searchConfig['funcName'])) return $this->session->set($module . 'searchParams', $searchConfig); - if($this->config->edition != 'open') $searchConfig = $this->searchTao->processBuildinFields($module, $searchConfig); $searchParams['module'] = $searchConfig['module']; From bc43a5a0537cba1fda1786c0be7bfd771a6cf1bf Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 09:25:19 +0800 Subject: [PATCH 12/32] * [perf] refactor: standardize search cache naming and parameter handling - Change session key from 'searchParams' to 'SearchFunc' for consistency - Simplify processSearchParams method to accept module name directly - Update method calls across search control and zen modules --- framework/model.class.php | 2 +- module/search/control.php | 4 ++-- module/search/zen.php | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/framework/model.class.php b/framework/model.class.php index 39e9cafd96..8832fb0ad8 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -315,7 +315,7 @@ class model extends baseModel $key++; } - $this->session->set($module . 'searchParams', ['funcModel' => $funcModel, 'funcName' => $methodName, 'funcArgs' => $funcArgs]); + $this->session->set($module . 'SearchFunc', ['funcModel' => $funcModel, 'funcName' => $methodName, 'funcArgs' => $funcArgs]); } /** diff --git a/module/search/control.php b/module/search/control.php index 1b069337a6..647d30224e 100644 --- a/module/search/control.php +++ b/module/search/control.php @@ -35,7 +35,7 @@ class search extends control $searchParams = $module . 'searchParams'; $searchForm = $module . 'Form'; - $this->searchZen->processSearchParams($searchParams); + $this->searchZen->processSearchParams($module); $fields = empty($fields) ? json_decode($_SESSION[$searchParams]['searchFields'], true) : $fields; $params = empty($params) ? json_decode($_SESSION[$searchParams]['fieldParams'], true) : $params; @@ -85,7 +85,7 @@ class search extends control $searchParams = $module . 'searchParams'; $searchForm = $module . 'Form'; - $this->searchZen->processSearchParams($searchParams); + $this->searchZen->processSearchParams($module); $fields = empty($fields) ? json_decode($_SESSION[$searchParams]['searchFields'], true) : $fields; $params = empty($params) ? json_decode($_SESSION[$searchParams]['fieldParams'], true) : $params; diff --git a/module/search/zen.php b/module/search/zen.php index fd99cdd137..33a602496c 100644 --- a/module/search/zen.php +++ b/module/search/zen.php @@ -6,15 +6,15 @@ class searchZen extends search * 构造搜索表单时调用被搜索模块的方法处理搜索参数。 * Call the method of the searched module to process search parameters when constructing the search form. * - * @param string $searchParams + * @param string $module * @access public * @return bool */ - public function processSearchParams(string $searchParams): bool + public function processSearchParams(string $module): bool { - $funcModel = $_SESSION[$searchParams]['funcModel'] ?? ''; - $funcName = $_SESSION[$searchParams]['funcName'] ?? ''; - $funcArgs = $_SESSION[$searchParams]['funcArgs'] ?? []; + $funcModel = $_SESSION[$module . 'SearchFunc']['funcModel'] ?? ''; + $funcName = $_SESSION[$module . 'SearchFunc']['funcName'] ?? ''; + $funcArgs = $_SESSION[$module . 'SearchFunc']['funcArgs'] ?? []; if(!$funcModel || !$funcName) return false; $funcArgs['cacheSearchParams'] = false; // 不缓存搜索参数以加载真实值。Do not cache search parameters to load real values. From 3d5bd5cca7f296eb650398db549abf061ff68bf5 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 09:40:55 +0800 Subject: [PATCH 13/32] * [perf] refactor: improve processSearchParams return handling and session access - Change return type from bool to array for better data flow - Replace direct $_SESSION access with $this->session for consistency - Add null check for funcArgs parameter validation - Return cached search parameters as fallback instead of false - Return actual function result instead of boolean success indicator --- module/search/zen.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/module/search/zen.php b/module/search/zen.php index 33a602496c..ab4a0d7780 100644 --- a/module/search/zen.php +++ b/module/search/zen.php @@ -8,18 +8,18 @@ class searchZen extends search * * @param string $module * @access public - * @return bool + * @return array */ - public function processSearchParams(string $module): bool + public function processSearchParams(string $module): array { - $funcModel = $_SESSION[$module . 'SearchFunc']['funcModel'] ?? ''; - $funcName = $_SESSION[$module . 'SearchFunc']['funcName'] ?? ''; - $funcArgs = $_SESSION[$module . 'SearchFunc']['funcArgs'] ?? []; - if(!$funcModel || !$funcName) return false; + $cacheKey = $module . 'SearchFunc'; + $funcModel = $this->session->$cacheKey['funcModel'] ?? ''; + $funcName = $this->session->$cacheKey['funcName'] ?? ''; + $funcArgs = $this->session->$cacheKey['funcArgs'] ?? []; + if(!$funcModel || !$funcName || !$funcArgs) return $this->session->{$module . 'searchParams'} ?? []; $funcArgs['cacheSearchParams'] = false; // 不缓存搜索参数以加载真实值。Do not cache search parameters to load real values. - $this->loadModel($funcModel)->$funcName(...$funcArgs); - return true; + return $this->loadModel($funcModel)->$funcName(...$funcArgs); } /** * 设置列表 session,方便返回。 From 1658fae2ff6bf303aff1041442550cc3ba1d4e7b Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 09:44:19 +0800 Subject: [PATCH 14/32] * [misc] Fix unittest error of the executionModel::buildTaskSearchForm method. --- .../test/lib/execution.unittest.class.php | 13 +++-- .../test/model/buildtasksearchform.php | 52 ++++++++++++++----- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/module/execution/test/lib/execution.unittest.class.php b/module/execution/test/lib/execution.unittest.class.php index fb44b4ae75..9a7e18a88c 100644 --- a/module/execution/test/lib/execution.unittest.class.php +++ b/module/execution/test/lib/execution.unittest.class.php @@ -2481,15 +2481,18 @@ class executionTest * Test build task search form. * * @param int $executionID + * @param int $productID + * @param array $executions * @param int $queryID + * @param string $actionURL + * @param string $module + * @param bool $cacheSearchParams * @access public - * @return int + * @return array */ - public function buildTaskSearchFormTest($executionID, $queryID) + public function buildTaskSearchFormTest($executionID, $productID, $executions, $queryID, $actionURL, $module, $cacheSearchParams) { - $this->executionModel->buildTaskSearchForm($executionID, array($executionID => 'yes'), $queryID, 'searchTask'); - - return $_SESSION['tasksearchParams']['queryID']; + return $this->executionModel->buildTaskSearchForm($executionID, $productID, $executions, $queryID, $actionURL, $module, $cacheSearchParams); } /** diff --git a/module/execution/test/model/buildtasksearchform.php b/module/execution/test/model/buildtasksearchform.php index 88db73d26d..d88393158f 100755 --- a/module/execution/test/model/buildtasksearchform.php +++ b/module/execution/test/model/buildtasksearchform.php @@ -44,20 +44,48 @@ title=测试executionModel->buildTaskSearchForm(); timeout=0 cid=1 -- 正确的执行,正确的queryID @1 -- 错误的执行,正确的queryID @1 -- 正确的执行,错误的queryID @0 -- 错误的执行,错误的queryID @0 -- 正确的执行,正确的queryID @2 +- 传递项目 ID,缓存查询参数,打印 queryID 的值。 @0 +- 传递项目 ID,缓存查询参数,打印 actionURL 的值。 @0 +- 传递项目 ID,缓存查询参数,打印所属执行列表。 @0 +- 传递项目 ID,不缓存查询参数,打印 queryID 的值。属性queryID @1 +- 传递项目 ID,不缓存查询参数,打印 actionURL 的值。属性actionURL @/execution-task-3-bySearch-myQueryID.html +- 传递项目 ID,不缓存查询参数,打印所属执行列表。 + - @~~ + - 属性3 @迭代1 + - 属性4 @迭代2 + - 属性5 @迭代3 +- 传递执行 ID,不缓存查询参数,打印 queryID 的值。属性queryID @1 +- 传递执行 ID,不缓存查询参数,打印 actionURL 的值。属性actionURL @/execution-task-3-bySearch-myQueryID.html +- 传递执行 ID,不缓存查询参数,打印所属执行列表。 + - @~~ + - 属性3 @迭代1 + - 属性4 @~~ + - 属性5 @~~ + - 属性all @所有执行 */ -$executionIDList = array('3', '0'); -$queryIDList = array('0', '1', '2'); +$projectID = 1; +$productID = 0; +$executionID = 3; +$executions = [3 => '迭代1', 4 => '迭代2', 5 => '迭代3']; +$queryID = 1; +$module = 'task'; +$actionURL = '/execution-task-3-bySearch-myQueryID.html'; $execution = new executionTest(); -r($execution->buildTaskSearchFormTest($executionIDList[0], $queryIDList[1])) && p() && e('1'); // 正确的执行,正确的queryID -r($execution->buildTaskSearchFormTest($executionIDList[1], $queryIDList[1])) && p() && e('1'); // 错误的执行,正确的queryID -r($execution->buildTaskSearchFormTest($executionIDList[0], $queryIDList[0])) && p() && e('0'); // 正确的执行,错误的queryID -r($execution->buildTaskSearchFormTest($executionIDList[1], $queryIDList[0])) && p() && e('0'); // 错误的执行,错误的queryID -r($execution->buildTaskSearchFormTest($executionIDList[1], $queryIDList[2])) && p() && e('2'); // 正确的执行,正确的queryID + +$searchConfig = $execution->buildTaskSearchFormTest($projectID, $productID, $executions, $queryID, $actionURL, $module, true); +r(isset($searchConfig['queryID'])) && p() && e(0); // 传递项目 ID,缓存查询参数,打印 queryID 的值。 +r(isset($searchConfig['actionURL'])) && p() && e(0); // 传递项目 ID,缓存查询参数,打印 actionURL 的值。 +r(isset($searchConfig['params']['execution']['values'])) && p() && e(0); // 传递项目 ID,缓存查询参数,打印所属执行列表。 + +$searchConfig = $execution->buildTaskSearchFormTest($projectID, $productID, $executions, $queryID, $actionURL, $module, false); +r($searchConfig) && p('queryID') && e('1'); // 传递项目 ID,不缓存查询参数,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/execution-task-3-bySearch-myQueryID.html'); // 传递项目 ID,不缓存查询参数,打印 actionURL 的值。 +r($searchConfig['params']['execution']['values']) && p(',3,4,5') && e('~~,迭代1,迭代2,迭代3'); // 传递项目 ID,不缓存查询参数,打印所属执行列表。 + +$searchConfig = $execution->buildTaskSearchFormTest($executionID, $productID, $executions, $queryID, $actionURL, $module, false); +r($searchConfig) && p('queryID') && e('1'); // 传递执行 ID,不缓存查询参数,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/execution-task-3-bySearch-myQueryID.html'); // 传递执行 ID,不缓存查询参数,打印 actionURL 的值。 +r($searchConfig['params']['execution']['values']) && p(',3,4,5,all') && e('~~,迭代1,~~,~~,所有执行'); // 传递执行 ID,不缓存查询参数,打印所属执行列表。 From 0807faa0ca50ffaa73907706ccc4445e54e86b48 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 10:38:57 +0800 Subject: [PATCH 15/32] * [misc] Fix unittest error of the myModel::buildTaskSearchForm method. --- module/my/test/lib/my.unittest.class.php | 12 ++-- module/my/test/model/buildtasksearchform.php | 75 +++++++++++++++----- 2 files changed, 63 insertions(+), 24 deletions(-) diff --git a/module/my/test/lib/my.unittest.class.php b/module/my/test/lib/my.unittest.class.php index 1b90a66a47..333a9c614c 100644 --- a/module/my/test/lib/my.unittest.class.php +++ b/module/my/test/lib/my.unittest.class.php @@ -269,16 +269,14 @@ class myTest * * @param int $queryID * @param string $actionURL + * @param string $rawMethod + * @param bool $cacheSearchParams * @access public - * @return array + * @return null|array */ - public function buildTaskSearchFormTest(int $queryID, string $actionURL): array + public function buildTaskSearchFormTest(int $queryID, string $actionURL, string $rawMethod, bool $cacheSearchParams): null|array { - $this->objectModel->buildTaskSearchForm($queryID, $actionURL); - - if(dao::isError()) return dao::getError(); - global $tester; - return $tester->config->execution->search; + return $this->objectModel->buildTaskSearchForm($queryID, $actionURL, $rawMethod, $cacheSearchParams); } /** diff --git a/module/my/test/model/buildtasksearchform.php b/module/my/test/model/buildtasksearchform.php index 9c4105c0e1..0af78f1f2e 100755 --- a/module/my/test/model/buildtasksearchform.php +++ b/module/my/test/model/buildtasksearchform.php @@ -4,7 +4,18 @@ declare(strict_types=1); include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/lib/my.unittest.class.php'; -zenData('user')->gen('1'); +zenData('user')->gen(1); + +$execution = zenData('project'); +$execution->id->range('1-5'); +$execution->name->range('项目1,项目2,迭代1,迭代2,迭代3'); +$execution->type->range('project{2},sprint,stage,kanban'); +$execution->path->range('1,2,`1,3`,`1,4`,`2,5`')->prefix(',')->postfix(','); +$execution->gen(5); + +$module = zenData('module'); +$module->name->range('1,2,3,4,5')->prefix('模块'); +$module->gen(5); su('admin'); @@ -14,22 +25,52 @@ title=测试 myModel->buildTaskSearchForm(); timeout=0 cid=1 -- 测试获取queryID 1 actionURL actionURL1 的搜索表单 - - 属性module @Task - - 属性queryID @0 - - 属性actionURL @actionURL1 -- 测试获取queryID 0 actionURL actionURL2 的搜索表单 - - 属性module @Task - - 属性queryID @1 - - 属性actionURL @actionURL2 - */ -$my = new myTest(); +$queryID = 1; +$rawMethod = 'contribute'; +$actionURL = "/my-{$rawMethod}-task.html"; +$my = new myTest(); -$queryID = array(0, 1); -$actionURL = array('actionURL1', 'actionURL2'); -$config1 = $my->buildTaskSearchFormTest($queryID[0], $actionURL[0]); -$config2 = $my->buildTaskSearchFormTest($queryID[1], $actionURL[1]); -r($config1) && p('module,queryID,actionURL') && e('Task,0,actionURL1'); // 测试获取queryID 1 actionURL actionURL1 的搜索表单 -r($config2) && p('module,queryID,actionURL') && e('Task,1,actionURL2'); // 测试获取queryID 0 actionURL actionURL2 的搜索表单 \ No newline at end of file +$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $rawMethod, true); +r(isset($searchConfig['module'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 module 为空。 +r(isset($searchConfig['queryID'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 queryID 为空。 +r(isset($searchConfig['actionURL'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 actionURL 为空。 +r(isset($searchConfig['fields'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 fields 为空。 +r(isset($searchConfig['params'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 params 为空。 + +$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $rawMethod, false); +r(isset($searchConfig['module'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询参数中 module 不为空。 +r(isset($searchConfig['queryID'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询参数中 queryID 不为空。 +r(isset($searchConfig['actionURL'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询参数中 actionURL 不为空。 +r(isset($searchConfig['fields']['closedReason'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedReason 不为空。 +r(isset($searchConfig['fields']['closedBy'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedBy 不为空。 +r(isset($searchConfig['fields']['closedDate'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedDate 不为空。 +r(isset($searchConfig['fields']['canceledBy'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 canceledBy 不为空。 +r(isset($searchConfig['fields']['canceledDate'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 canceledDate 不为空。 + +r($searchConfig) && p('module') && e('contributeTask'); // 不缓存查询参数,rawMethod 为 contribute,打印 module 的值。 +r($searchConfig) && p('queryID') && e('1'); // 不缓存查询参数,rawMethod 为 contribute,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/my-contribute-task.html'); // 不缓存查询参数,rawMethod 为 contribute,打印 actionURL 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // 不缓存查询参数,rawMethod 为 contribute,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // 不缓存查询参数,rawMethod 为 contribute,打印所属执行列表。 +r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('/,~~,/模块2,~~,~~,/模块5'); // 不缓存查询参数,rawMethod 为 contribute,打印所属模块列表。 + +$rawMethod = 'work'; +$actionURL = "/my-{$rawMethod}-task.html"; +$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $rawMethod, false); +r(isset($searchConfig['module'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 work,查询参数中 module 不为空。 +r(isset($searchConfig['queryID'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 work,查询参数中 queryID 不为空。 +r(isset($searchConfig['actionURL'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 work,查询参数中 actionURL 不为空。 +r(isset($searchConfig['fields']['closedReason'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 closedReason 为空。 +r(isset($searchConfig['fields']['closedBy'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 closedBy 为空。 +r(isset($searchConfig['fields']['closedDate'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 closedDate 为空。 +r(isset($searchConfig['fields']['canceledBy'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 canceledBy 为空。 +r(isset($searchConfig['fields']['canceledDate'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 canceledDate 为空。 + +r($searchConfig) && p('module') && e('workTask'); // 不缓存查询参数,rawMethod 为 work,打印 module 的值。 +r($searchConfig) && p('queryID') && e('1'); // 不缓存查询参数,rawMethod 为 work,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/my-work-task.html'); // 不缓存查询参数,rawMethod 为 work,打印 actionURL 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // 不缓存查询参数,rawMethod 为 work,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // 不缓存查询参数,rawMethod 为 work,打印所属执行列表。 +r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('/,~~,/模块2,~~,~~,/模块5'); // 不缓存查询参数,rawMethod 为 work,打印所属模块列表。 From 69ffa9b44d97498f1cbf6c2308b76cdbd5905d13 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 10:40:04 +0800 Subject: [PATCH 16/32] + [misc] Add unittest steps of the myModel::buildTaskSearchForm method. --- module/my/test/model/buildtasksearchform.php | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/module/my/test/model/buildtasksearchform.php b/module/my/test/model/buildtasksearchform.php index 0af78f1f2e..9382436fbd 100755 --- a/module/my/test/model/buildtasksearchform.php +++ b/module/my/test/model/buildtasksearchform.php @@ -25,6 +25,38 @@ title=测试 myModel->buildTaskSearchForm(); timeout=0 cid=1 +- 缓存查询参数,rawMethod 为 contribute,查询参数中 module 为空。 @0 +- 缓存查询参数,rawMethod 为 contribute,查询参数中 queryID 为空。 @0 +- 缓存查询参数,rawMethod 为 contribute,查询参数中 actionURL 为空。 @0 +- 缓存查询参数,rawMethod 为 contribute,查询参数中 fields 为空。 @0 +- 缓存查询参数,rawMethod 为 contribute,查询参数中 params 为空。 @0 +- 不缓存查询参数,rawMethod 为 contribute,查询参数中 module 不为空。 @1 +- 不缓存查询参数,rawMethod 为 contribute,查询参数中 queryID 不为空。 @1 +- 不缓存查询参数,rawMethod 为 contribute,查询参数中 actionURL 不为空。 @1 +- 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedReason 不为空。 @1 +- 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedBy 不为空。 @1 +- 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedDate 不为空。 @1 +- 不缓存查询参数,rawMethod 为 contribute,查询字段中 canceledBy 不为空。 @1 +- 不缓存查询参数,rawMethod 为 contribute,查询字段中 canceledDate 不为空。 @1 +- 不缓存查询参数,rawMethod 为 contribute,打印 module 的值。属性module @contributeTask +- 不缓存查询参数,rawMethod 为 contribute,打印 queryID 的值。属性queryID @1 +- 不缓存查询参数,rawMethod 为 contribute,打印 actionURL 的值。属性actionURL @/my-contribute-task.html +- 不缓存查询参数,rawMethod 为 contribute,打印所属项目列表。 + - 属性1 @项目1 + - 属性2 @项目2 + - 属性all @所有项目 +- 不缓存查询参数,rawMethod 为 contribute,打印所属执行列表。 + - 属性3 @/迭代1 + - 属性4 @/迭代2 + - 属性5 @/迭代3 + - 属性all @所有执行 +- 不缓存查询参数,rawMethod 为 contribute,打印所属模块列表。 + - @/ + - 属性1 @~~ + - 属性2 @/模块2 + - 属性3 @~~ + - 属性4 @~~ + - 属性5 @/模块5 */ $queryID = 1; From a8fb172c94c4fe12118475dd38e77b45267621df Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 10:40:43 +0800 Subject: [PATCH 17/32] + [misc] Add unittest steps of the myModel::buildTaskSearchForm method. --- module/my/test/model/buildtasksearchform.php | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/module/my/test/model/buildtasksearchform.php b/module/my/test/model/buildtasksearchform.php index 9382436fbd..94aad864a8 100755 --- a/module/my/test/model/buildtasksearchform.php +++ b/module/my/test/model/buildtasksearchform.php @@ -57,6 +57,34 @@ cid=1 - 属性3 @~~ - 属性4 @~~ - 属性5 @/模块5 +- 不缓存查询参数,rawMethod 为 work,查询参数中 module 不为空。 @1 +- 不缓存查询参数,rawMethod 为 work,查询参数中 queryID 不为空。 @1 +- 不缓存查询参数,rawMethod 为 work,查询参数中 actionURL 不为空。 @1 +- 不缓存查询参数,rawMethod 为 work,查询字段中 closedReason 为空。 @0 +- 不缓存查询参数,rawMethod 为 work,查询字段中 closedBy 为空。 @0 +- 不缓存查询参数,rawMethod 为 work,查询字段中 closedDate 为空。 @0 +- 不缓存查询参数,rawMethod 为 work,查询字段中 canceledBy 为空。 @0 +- 不缓存查询参数,rawMethod 为 work,查询字段中 canceledDate 为空。 @0 +- 不缓存查询参数,rawMethod 为 work,打印 module 的值。属性module @workTask +- 不缓存查询参数,rawMethod 为 work,打印 queryID 的值。属性queryID @1 +- 不缓存查询参数,rawMethod 为 work,打印 actionURL 的值。属性actionURL @/my-work-task.html +- 不缓存查询参数,rawMethod 为 work,打印所属项目列表。 + - 属性1 @项目1 + - 属性2 @项目2 + - 属性all @所有项目 +- 不缓存查询参数,rawMethod 为 work,打印所属执行列表。 + - 属性3 @/迭代1 + - 属性4 @/迭代2 + - 属性5 @/迭代3 + - 属性all @所有执行 +- 不缓存查询参数,rawMethod 为 work,打印所属模块列表。 + - @/ + - 属性1 @~~ + - 属性2 @/模块2 + - 属性3 @~~ + - 属性4 @~~ + - 属性5 @/模块5 + */ $queryID = 1; From 7cad0bbc79b287bfffa42de38145194d1dff6115 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 11:07:15 +0800 Subject: [PATCH 18/32] * [perf] Move the processSearchParams method from searchZen to searchModel. --- module/search/model.php | 19 +++++++++++++++++++ module/search/zen.php | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/module/search/model.php b/module/search/model.php index 5d40873849..5124cb5256 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -13,6 +13,25 @@ session->$cacheKey['funcModel'] ?? ''; + $funcName = $this->session->$cacheKey['funcName'] ?? ''; + $funcArgs = $this->session->$cacheKey['funcArgs'] ?? []; + if(!$funcModel || !$funcName || !$funcArgs) return $this->session->{$module . 'searchParams'} ?? []; + + $funcArgs['cacheSearchParams'] = false; // 不缓存搜索参数以加载真实值。Do not cache search parameters to load real values. + return $this->loadModel($funcModel)->$funcName(...$funcArgs); + } /** * 设置搜索参数的session。 diff --git a/module/search/zen.php b/module/search/zen.php index ab4a0d7780..aa0746e518 100644 --- a/module/search/zen.php +++ b/module/search/zen.php @@ -2,25 +2,6 @@ declare(strict_types=1); class searchZen extends search { - /** - * 构造搜索表单时调用被搜索模块的方法处理搜索参数。 - * Call the method of the searched module to process search parameters when constructing the search form. - * - * @param string $module - * @access public - * @return array - */ - public function processSearchParams(string $module): array - { - $cacheKey = $module . 'SearchFunc'; - $funcModel = $this->session->$cacheKey['funcModel'] ?? ''; - $funcName = $this->session->$cacheKey['funcName'] ?? ''; - $funcArgs = $this->session->$cacheKey['funcArgs'] ?? []; - if(!$funcModel || !$funcName || !$funcArgs) return $this->session->{$module . 'searchParams'} ?? []; - - $funcArgs['cacheSearchParams'] = false; // 不缓存搜索参数以加载真实值。Do not cache search parameters to load real values. - return $this->loadModel($funcModel)->$funcName(...$funcArgs); - } /** * 设置列表 session,方便返回。 * Set list in session, for come back search index page. From cf956eaacde2598c0fd53a70b155f0c70e236c6c Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 11:08:10 +0800 Subject: [PATCH 19/32] * [perf] If the search function has been cached don't save search fields and parameters into session. --- module/search/model.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/module/search/model.php b/module/search/model.php index 5124cb5256..78d265b09c 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -47,13 +47,17 @@ class searchModel extends model if($this->config->edition != 'open') $searchConfig = $this->searchTao->processBuildinFields($module, $searchConfig); - $searchParams['module'] = $searchConfig['module']; - $searchParams['searchFields'] = json_encode($searchConfig['fields']); - $searchParams['fieldParams'] = json_encode($searchConfig['params']); - $searchParams['actionURL'] = $searchConfig['actionURL']; - $searchParams['style'] = zget($searchConfig, 'style', 'full'); - $searchParams['onMenuBar'] = zget($searchConfig, 'onMenuBar', 'no'); - $searchParams['queryID'] = isset($searchConfig['queryID']) ? $searchConfig['queryID'] : 0; + $searchParams['module'] = $searchConfig['module']; + $searchParams['actionURL'] = $searchConfig['actionURL']; + $searchParams['style'] = zget($searchConfig, 'style', 'full'); + $searchParams['onMenuBar'] = zget($searchConfig, 'onMenuBar', 'no'); + $searchParams['queryID'] = isset($searchConfig['queryID']) ? $searchConfig['queryID'] : 0; + + if(empty($_SESSION[$module . 'SearchFunc'])) + { + $searchParams['searchFields'] = $searchConfig['fields']; + $searchParams['fieldParams'] = $searchConfig['params']; + } $this->session->set($module . 'searchParams', $searchParams); } From 3ef2691fd45ffaccad8ad85e2fb31bb7a7f7ac7c Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 11:09:22 +0800 Subject: [PATCH 20/32] * [perf] IF the search function has been cached get search fields and parameters from configuration items instead of session. --- module/search/control.php | 16 ++++++---------- module/search/model.php | 8 +++++--- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/module/search/control.php b/module/search/control.php index 647d30224e..e3da90eed0 100644 --- a/module/search/control.php +++ b/module/search/control.php @@ -34,11 +34,9 @@ class search extends control $module = empty($module) ? $this->session->searchParams['module'] : $module; $searchParams = $module . 'searchParams'; $searchForm = $module . 'Form'; - - $this->searchZen->processSearchParams($module); - - $fields = empty($fields) ? json_decode($_SESSION[$searchParams]['searchFields'], true) : $fields; - $params = empty($params) ? json_decode($_SESSION[$searchParams]['fieldParams'], true) : $params; + $searchConfig = $this->search->processSearchParams($module); + $fields = $searchConfig['fields'] ?? $fields; + $params = $searchConfig['params'] ?? $params; $_SESSION['searchParams']['module'] = $module; if(empty($_SESSION[$searchForm])) $this->search->initSession($module, $fields, $params); @@ -84,11 +82,9 @@ class search extends control $module = empty($module) ? $this->session->searchParams['module'] : $module; $searchParams = $module . 'searchParams'; $searchForm = $module . 'Form'; - - $this->searchZen->processSearchParams($module); - - $fields = empty($fields) ? json_decode($_SESSION[$searchParams]['searchFields'], true) : $fields; - $params = empty($params) ? json_decode($_SESSION[$searchParams]['fieldParams'], true) : $params; + $searchConfig = $this->search->processSearchParams($module); + $fields = $searchConfig['fields'] ?? $fields; + $params = $searchConfig['fields'] ?? $params; $_SESSION['searchParams']['module'] = $module; if(empty($_SESSION[$searchForm])) $this->search->initOldSession($module, $fields, $params); diff --git a/module/search/model.php b/module/search/model.php index 78d265b09c..fb1e0c7cf4 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -120,8 +120,9 @@ class searchModel extends model /* Init vars. */ $module = $this->post->module; $searchParams = $module . 'searchParams'; - $searchFields = json_decode($_SESSION[$searchParams]['searchFields']); - $fieldParams = json_decode($_SESSION[$searchParams]['fieldParams']); + $searchConfig = $this->processSearchParams($module); + $searchFields = $searchConfig['fields']; + $fieldParams = $searchConfig['params']; $groupItems = $this->config->search->groupItems; $groupAndOr = strtoupper($this->post->groupAndOr); if($groupAndOr != 'AND' && $groupAndOr != 'OR') $groupAndOr = 'AND'; @@ -193,7 +194,8 @@ class searchModel extends model $groupAndOr = strtoupper($this->post->groupAndOr); $module = $this->post->module; $searchParams = $module . 'searchParams'; - $fieldParams = json_decode($_SESSION[$searchParams]['fieldParams']); + $searchConfig = $this->processSearchParams($module); + $fieldParams = $searchConfig['params']; $scoreNum = 0; if($groupAndOr != 'AND' and $groupAndOr != 'OR') $groupAndOr = 'AND'; From 9197a66de1c7f3545eba512313e10db39aa6dcd8 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 11:18:44 +0800 Subject: [PATCH 21/32] * [perf] If the search function has been cached return the search configuration items. --- module/execution/model.php | 8 ++++++-- module/my/control.php | 2 +- module/my/model.php | 16 +++++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index f8d9e2f2d3..61f61b991f 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4179,9 +4179,13 @@ class executionModel extends model */ public function buildTaskSearchForm(int $executionID, int $productID, array $executions, int $queryID, string $actionURL, string $module = 'task', bool $cacheSearchParams = true) { - if($cacheSearchParams) return $this->cacheSearchParams($module, __METHOD__, func_get_args()); - $searchConfig = $this->config->execution->search; + if($cacheSearchParams) + { + $this->cacheSearchParams($module, __METHOD__, func_get_args()); + return $searchConfig; + } + $searchConfig['module'] = $module; $searchConfig['actionURL'] = $actionURL; $searchConfig['queryID'] = $queryID; diff --git a/module/my/control.php b/module/my/control.php index ee7173a6c9..dc565f531d 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -434,7 +434,7 @@ class my extends control $tasks = $this->myZen->buildTaskData($tasks); $actionURL = $this->createLink('my', $this->app->rawMethod, "mode=task&browseType=bySearch&queryID=myQueryID"); - $this->my->buildTaskSearchForm($queryID, $actionURL, $this->app->rawMethod); + $this->my->buildTaskSearchForm($queryID, $actionURL, $this->app->rawMethod . 'Task'); $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID); diff --git a/module/my/model.php b/module/my/model.php index 86334685dc..86e7a56af5 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -448,24 +448,26 @@ class myModel extends model * * @param int $queryID * @param string $actionURL - * @param string $rawMethod + * @param string $module * @param bool $cacheSearchParams 是否缓存搜索参数。默认缓存可以提高性能,构造搜索表单时再加载真实值。 * @access public * @return void */ - public function buildTaskSearchForm(int $queryID, string $actionURL, string $rawMethod, bool $cacheSearchParams = true) + public function buildTaskSearchForm(int $queryID, string $actionURL, string $module, bool $cacheSearchParams = true) { - $module = $rawMethod . 'Task'; - if($cacheSearchParams) return $this->cacheSearchParams($module, __METHOD__, func_get_args()); - $this->loadModel('execution'); - $searchConfig = $this->config->execution->search; + if($cacheSearchParams) + { + $this->cacheSearchParams($module, __METHOD__, func_get_args()); + return $searchConfig; + } + $searchConfig['module'] = $module; $searchConfig['actionURL'] = $actionURL; $searchConfig['queryID'] = $queryID; - if($rawMethod == 'work') + if($module == 'workTask') { unset($searchConfig['fields']['closedReason']); unset($searchConfig['fields']['closedBy']); From 1cc1143ae7f939953ab8ebbab72d88020318a0ed Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 11:33:49 +0800 Subject: [PATCH 22/32] * [perf] Refactor: convert object property access to array access in search module. --- module/search/model.php | 12 ++++++------ module/search/tao.php | 15 +++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/module/search/model.php b/module/search/model.php index fb1e0c7cf4..c532f81a7e 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -146,12 +146,12 @@ class searchModel extends model $field = $this->post->$fieldName; $value = $this->post->$valueName; - $fieldControl = isset($fieldParams->$field) && isset($fieldParams->{$field}->control) ? $fieldParams->{$field}->control : ''; + $fieldControl = isset($fieldParams[$field]) && isset($fieldParams[$field]['control']) ? $fieldParams[$field]['control'] : ''; if(empty($field) || $value === '' || $value === false) continue; // false means no exist this post item. '' means no search data. ignore it. if(!preg_match('/^[a-zA-Z0-9]+$/', $field)) continue; // Fix sql injection. /* 如果是输入框,并且输入框的值为'0',或者 id 的值为'0',将值设置为zero。*/ - if(isset($fieldParams->$field) && $fieldControl == 'input' && $value === '0') $this->post->set($valueName, 'ZERO'); + if(isset($fieldParams[$field]) && $fieldControl == 'input' && $value === '0') $this->post->set($valueName, 'ZERO'); if($field == 'id' && $value === '0') $this->post->set($valueName, 'ZERO'); /* set queryForm. */ @@ -215,13 +215,13 @@ class searchModel extends model /* Fix bug #2704. */ $field = $this->post->$fieldName; if(!preg_match('/^[a-zA-Z0-9]+$/', $field)) continue; // Fix sql injection. - if(isset($fieldParams->$field) and $fieldParams->$field->control == 'input' and $this->post->$valueName === '0') $this->post->set($valueName, 'ZERO'); + if(isset($fieldParams[$field]) and $fieldParams[$field]['control'] == 'input' and $this->post->$valueName === '0') $this->post->set($valueName, 'ZERO'); if($field == 'id' and $this->post->$valueName === '0') $this->post->set($valueName, 'ZERO'); /* Skip empty values. */ if($this->post->$valueName == false) continue; if($this->post->$valueName == 'ZERO') $this->post->$valueName = 0; // ZERO is special, stands to 0. - if(isset($fieldParams->$field) and $fieldParams->$field->control == 'select' and $this->post->$valueName === 'null') $this->post->set($valueName, ''); // Null is special, stands to empty if control is select. Fix bug #3279. + if(isset($fieldParams[$field]) and $fieldParams[$field]['control'] == 'select' and $this->post->$valueName === 'null') $this->post->set($valueName, ''); // Null is special, stands to empty if control is select. Fix bug #3279. $scoreNum += 1; @@ -245,7 +245,7 @@ class searchModel extends model } else { - $condition = $fieldParams->$field->control == 'select' ? " LIKE CONCAT('%,', '{$value}', ',%')" : ' LIKE ' . $this->dbh->quote("%$value%"); + $condition = $fieldParams[$field]['control'] == 'select' ? " LIKE CONCAT('%,', '{$value}', ',%')" : ' LIKE ' . $this->dbh->quote("%$value%"); } } elseif($operator == "notinclude") @@ -257,7 +257,7 @@ class searchModel extends model } else { - $condition = $fieldParams->$field->control == 'select' ? " NOT LIKE CONCAT('%,', '{$value}', ',%')" : ' NOT LIKE ' . $this->dbh->quote("%$value%"); + $condition = $fieldParams[$field]['control'] == 'select' ? " NOT LIKE CONCAT('%,', '{$value}', ',%')" : ' NOT LIKE ' . $this->dbh->quote("%$value%"); } } elseif($operator == 'belong') diff --git a/module/search/tao.php b/module/search/tao.php index d4150d9db4..26324e9430 100644 --- a/module/search/tao.php +++ b/module/search/tao.php @@ -76,15 +76,14 @@ class searchTao extends searchModel * 初始化搜索表单,并且保存到 session。 * Init the search session for the first time search. * - * @param string $module - * @param object|array $fields - * @param object|array $fieldParams + * @param string $module + * @param array $fields + * @param array $fieldParams * @access public * @return array */ - public function initSession(string $module, object|array $fields, object|array $fieldParams): array + public function initSession(string $module, array $fields, array $fieldParams): array { - if(is_object($fields)) $fields = get_object_vars($fields); $formSessionName = $module . 'Form'; $queryForm = array(); @@ -143,7 +142,7 @@ class searchTao extends searchModel * 处理查询表单的相关数据。 * Process query form datas. * - * @param object $fieldParams + * @param array $fieldParams * @param string $field * @param string $andOrName * @param string $operatorName @@ -151,7 +150,7 @@ class searchTao extends searchModel * @access public * @return array */ - public function processQueryFormDatas(object $fieldParams, string $field, string $andOrName, string $operatorName, string $valueName): array + public function processQueryFormDatas(array $fieldParams, string $field, string $andOrName, string $operatorName, string $valueName): array { /* 设置分组之间的逻辑关系。*/ /* Set and or. */ @@ -167,7 +166,7 @@ class searchTao extends searchModel /* Skip empty values. */ $value = $this->post->$valueName; if($value == 'ZERO') $this->post->set($valueName, 0); // ZERO is special, stands to 0. - if(isset($fieldParams->$field) && $fieldParams->$field->control == 'select' && $value === 'null') $this->post->set($valueName, ''); // Null is special, stands to empty if control is select. + if(isset($fieldParams[$field]) && $fieldParams[$field]['control'] == 'select' && $value === 'null') $this->post->set($valueName, ''); // Null is special, stands to empty if control is select. $value = addcslashes(trim((string)$this->post->{$valueName}), '%'); return array($andOr, $operator, $value); From 291afb4f2cb4c6db1b558373ae0172f9b68b8397 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 11:50:20 +0800 Subject: [PATCH 23/32] * [perf] Optimize search module variable usage and simplify field control access. --- module/search/control.php | 2 +- module/search/model.php | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/module/search/control.php b/module/search/control.php index e3da90eed0..86000bde2f 100644 --- a/module/search/control.php +++ b/module/search/control.php @@ -55,7 +55,7 @@ class search extends control $this->view->queryID = (empty($module) && empty($queryID)) ? $_SESSION[$searchParams]['queryID'] : $queryID; $this->view->style = !empty($_SESSION[$searchParams]['style']) ? $_SESSION[$searchParams]['style'] : 'full'; $this->view->onMenuBar = !empty($_SESSION[$searchParams]['onMenuBar']) ? $_SESSION[$searchParams]['onMenuBar'] : 'no'; - $this->view->formSession = $_SESSION[$module . 'Form']; + $this->view->formSession = $_SESSION[$searchForm]; $this->view->formName = $formName; if($module == 'program') $this->view->options = $this->searchZen->setOptions($fields, $this->view->fieldParams, $this->view->queries); diff --git a/module/search/model.php b/module/search/model.php index c532f81a7e..92566d7d4b 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -47,7 +47,7 @@ class searchModel extends model if($this->config->edition != 'open') $searchConfig = $this->searchTao->processBuildinFields($module, $searchConfig); - $searchParams['module'] = $searchConfig['module']; + $searchParams['module'] = $module; $searchParams['actionURL'] = $searchConfig['actionURL']; $searchParams['style'] = zget($searchConfig, 'style', 'full'); $searchParams['onMenuBar'] = zget($searchConfig, 'onMenuBar', 'no'); @@ -119,7 +119,6 @@ class searchModel extends model { /* Init vars. */ $module = $this->post->module; - $searchParams = $module . 'searchParams'; $searchConfig = $this->processSearchParams($module); $searchFields = $searchConfig['fields']; $fieldParams = $searchConfig['params']; @@ -146,12 +145,12 @@ class searchModel extends model $field = $this->post->$fieldName; $value = $this->post->$valueName; - $fieldControl = isset($fieldParams[$field]) && isset($fieldParams[$field]['control']) ? $fieldParams[$field]['control'] : ''; + $fieldControl = $fieldParams[$field]['control'] ?? ''; if(empty($field) || $value === '' || $value === false) continue; // false means no exist this post item. '' means no search data. ignore it. if(!preg_match('/^[a-zA-Z0-9]+$/', $field)) continue; // Fix sql injection. /* 如果是输入框,并且输入框的值为'0',或者 id 的值为'0',将值设置为zero。*/ - if(isset($fieldParams[$field]) && $fieldControl == 'input' && $value === '0') $this->post->set($valueName, 'ZERO'); + if($fieldControl == 'input' && $value === '0') $this->post->set($valueName, 'ZERO'); if($field == 'id' && $value === '0') $this->post->set($valueName, 'ZERO'); /* set queryForm. */ @@ -193,7 +192,6 @@ class searchModel extends model $groupItems = $this->config->search->groupItems; $groupAndOr = strtoupper($this->post->groupAndOr); $module = $this->post->module; - $searchParams = $module . 'searchParams'; $searchConfig = $this->processSearchParams($module); $fieldParams = $searchConfig['params']; $scoreNum = 0; @@ -215,13 +213,15 @@ class searchModel extends model /* Fix bug #2704. */ $field = $this->post->$fieldName; if(!preg_match('/^[a-zA-Z0-9]+$/', $field)) continue; // Fix sql injection. - if(isset($fieldParams[$field]) and $fieldParams[$field]['control'] == 'input' and $this->post->$valueName === '0') $this->post->set($valueName, 'ZERO'); + + $fieldControl = $fieldParams[$field]['control'] ?? ''; + if($fieldControl == 'input' and $this->post->$valueName === '0') $this->post->set($valueName, 'ZERO'); if($field == 'id' and $this->post->$valueName === '0') $this->post->set($valueName, 'ZERO'); /* Skip empty values. */ if($this->post->$valueName == false) continue; if($this->post->$valueName == 'ZERO') $this->post->$valueName = 0; // ZERO is special, stands to 0. - if(isset($fieldParams[$field]) and $fieldParams[$field]['control'] == 'select' and $this->post->$valueName === 'null') $this->post->set($valueName, ''); // Null is special, stands to empty if control is select. Fix bug #3279. + if($fieldControl == 'select' and $this->post->$valueName === 'null') $this->post->set($valueName, ''); // Null is special, stands to empty if control is select. Fix bug #3279. $scoreNum += 1; @@ -245,7 +245,7 @@ class searchModel extends model } else { - $condition = $fieldParams[$field]['control'] == 'select' ? " LIKE CONCAT('%,', '{$value}', ',%')" : ' LIKE ' . $this->dbh->quote("%$value%"); + $condition = $fieldControl == 'select' ? " LIKE CONCAT('%,', '{$value}', ',%')" : ' LIKE ' . $this->dbh->quote("%$value%"); } } elseif($operator == "notinclude") @@ -257,7 +257,7 @@ class searchModel extends model } else { - $condition = $fieldParams[$field]['control'] == 'select' ? " NOT LIKE CONCAT('%,', '{$value}', ',%')" : ' NOT LIKE ' . $this->dbh->quote("%$value%"); + $condition = $fieldControl == 'select' ? " NOT LIKE CONCAT('%,', '{$value}', ',%')" : ' NOT LIKE ' . $this->dbh->quote("%$value%"); } } elseif($operator == 'belong') From d67ab3ca2237cb014e4abb2393074ffc8f115548 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 13:04:42 +0800 Subject: [PATCH 24/32] * [perf] Add cacheSearchParams parameter to processSearchParams method for performance control. --- module/search/model.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/module/search/model.php b/module/search/model.php index 92566d7d4b..675eb7ed4e 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -18,10 +18,11 @@ class searchModel extends model * Call the method of the searched module to process search parameters when constructing the search form. * * @param string $module + * @param bool @cacheSearchParams // 是否缓存搜索参数。默认不缓存以加载真实值。Whether to cache search parameters. Default is not to cache to load real values. * @access public * @return array */ - public function processSearchParams(string $module): array + public function processSearchParams(string $module, bool $cacheSearchParams = false): array { $cacheKey = $module . 'SearchFunc'; $funcModel = $this->session->$cacheKey['funcModel'] ?? ''; @@ -29,7 +30,7 @@ class searchModel extends model $funcArgs = $this->session->$cacheKey['funcArgs'] ?? []; if(!$funcModel || !$funcName || !$funcArgs) return $this->session->{$module . 'searchParams'} ?? []; - $funcArgs['cacheSearchParams'] = false; // 不缓存搜索参数以加载真实值。Do not cache search parameters to load real values. + $funcArgs['cacheSearchParams'] = $cacheSearchParams; return $this->loadModel($funcModel)->$funcName(...$funcArgs); } @@ -119,7 +120,7 @@ class searchModel extends model { /* Init vars. */ $module = $this->post->module; - $searchConfig = $this->processSearchParams($module); + $searchConfig = $this->processSearchParams($module, true); $searchFields = $searchConfig['fields']; $fieldParams = $searchConfig['params']; $groupItems = $this->config->search->groupItems; @@ -192,7 +193,7 @@ class searchModel extends model $groupItems = $this->config->search->groupItems; $groupAndOr = strtoupper($this->post->groupAndOr); $module = $this->post->module; - $searchConfig = $this->processSearchParams($module); + $searchConfig = $this->processSearchParams($module, true); $fieldParams = $searchConfig['params']; $scoreNum = 0; From fc59f9b6b5085e991913d3b4f96e98683cf3bd60 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 13:59:15 +0800 Subject: [PATCH 25/32] * [misc] Fix unittest error of the myModel::buildTaskSearchForm method. --- module/my/test/lib/my.unittest.class.php | 6 +- module/my/test/model/buildtasksearchform.php | 203 +++++++++++-------- 2 files changed, 118 insertions(+), 91 deletions(-) diff --git a/module/my/test/lib/my.unittest.class.php b/module/my/test/lib/my.unittest.class.php index 333a9c614c..d7fcf5d333 100644 --- a/module/my/test/lib/my.unittest.class.php +++ b/module/my/test/lib/my.unittest.class.php @@ -269,14 +269,14 @@ class myTest * * @param int $queryID * @param string $actionURL - * @param string $rawMethod + * @param string $module * @param bool $cacheSearchParams * @access public * @return null|array */ - public function buildTaskSearchFormTest(int $queryID, string $actionURL, string $rawMethod, bool $cacheSearchParams): null|array + public function buildTaskSearchFormTest(int $queryID, string $actionURL, string $module, bool $cacheSearchParams): null|array { - return $this->objectModel->buildTaskSearchForm($queryID, $actionURL, $rawMethod, $cacheSearchParams); + return $this->objectModel->buildTaskSearchForm($queryID, $actionURL, $module, $cacheSearchParams); } /** diff --git a/module/my/test/model/buildtasksearchform.php b/module/my/test/model/buildtasksearchform.php index 94aad864a8..2110f78198 100755 --- a/module/my/test/model/buildtasksearchform.php +++ b/module/my/test/model/buildtasksearchform.php @@ -25,112 +25,139 @@ title=测试 myModel->buildTaskSearchForm(); timeout=0 cid=1 -- 缓存查询参数,rawMethod 为 contribute,查询参数中 module 为空。 @0 -- 缓存查询参数,rawMethod 为 contribute,查询参数中 queryID 为空。 @0 -- 缓存查询参数,rawMethod 为 contribute,查询参数中 actionURL 为空。 @0 -- 缓存查询参数,rawMethod 为 contribute,查询参数中 fields 为空。 @0 -- 缓存查询参数,rawMethod 为 contribute,查询参数中 params 为空。 @0 -- 不缓存查询参数,rawMethod 为 contribute,查询参数中 module 不为空。 @1 -- 不缓存查询参数,rawMethod 为 contribute,查询参数中 queryID 不为空。 @1 -- 不缓存查询参数,rawMethod 为 contribute,查询参数中 actionURL 不为空。 @1 -- 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedReason 不为空。 @1 -- 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedBy 不为空。 @1 -- 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedDate 不为空。 @1 -- 不缓存查询参数,rawMethod 为 contribute,查询字段中 canceledBy 不为空。 @1 -- 不缓存查询参数,rawMethod 为 contribute,查询字段中 canceledDate 不为空。 @1 -- 不缓存查询参数,rawMethod 为 contribute,打印 module 的值。属性module @contributeTask -- 不缓存查询参数,rawMethod 为 contribute,打印 queryID 的值。属性queryID @1 -- 不缓存查询参数,rawMethod 为 contribute,打印 actionURL 的值。属性actionURL @/my-contribute-task.html -- 不缓存查询参数,rawMethod 为 contribute,打印所属项目列表。 +- module 为 workTask,缓存查询参数,查询参数中 queryID 为空。 @0 +- module 为 workTask,缓存查询参数,查询参数中 actionURL 为空。 @0 +- module 为 workTask,缓存查询参数,查询字段中 closedReason 不为空。 @1 +- module 为 workTask,缓存查询参数,查询字段中 closedBy 不为空。 @1 +- module 为 workTask,缓存查询参数,查询字段中 closedDate 不为空。 @1 +- module 为 workTask,缓存查询参数,查询字段中 canceledBy 不为空。 @1 +- module 为 workTask,缓存查询参数,查询字段中 canceledDate 不为空。 @1 +- module 为 workTask,缓存查询参数,打印 module 的值。属性module @task +- module 为 workTask,缓存查询参数,打印 queryID 的值。属性queryID @~~ +- module 为 workTask,缓存查询参数,打印 actionURL 的值。属性actionURL @~~ +- module 为 workTask,缓存查询参数,打印所属项目列表。 + - 属性1 @0 + - 属性2 @0 + - 属性all @0 +- module 为 workTask,缓存查询参数,打印所属执行列表。 + - 属性3 @0 + - 属性4 @0 + - 属性5 @0 + - 属性all @0 +- module 为 workTask,缓存查询参数,打印所属模块列表。 + - @0 + - 属性1 @0 + - 属性2 @0 + - 属性3 @0 + - 属性4 @0 + - 属性5 @0 +- module 为 workTask,不缓存查询参数,查询参数中 queryID 不为空。 @1 +- module 为 workTask,不缓存查询参数,查询参数中 actionURL 不为空。 @1 +- module 为 workTask,不缓存查询参数,查询字段中 closedReason 为空。 @0 +- module 为 workTask,不缓存查询参数,查询字段中 closedBy 为空。 @0 +- module 为 workTask,不缓存查询参数,查询字段中 closedDate 为空。 @0 +- module 为 workTask,不缓存查询参数,查询字段中 canceledBy 为空。 @0 +- module 为 workTask,不缓存查询参数,查询字段中 canceledDate 为空。 @0 +- module 为 workTask,不缓存查询参数,打印 module 的值。属性module @workTask +- module 为 workTask,不缓存查询参数,打印 queryID 的值。属性queryID @1 +- module 为 workTask,不缓存查询参数,打印 actionURL 的值。属性actionURL @/my-work-task.html +- module 为 workTask,不缓存查询参数,打印所属项目列表。 - 属性1 @项目1 - 属性2 @项目2 - 属性all @所有项目 -- 不缓存查询参数,rawMethod 为 contribute,打印所属执行列表。 +- module 为 workTask,不缓存查询参数,打印所属执行列表。 - 属性3 @/迭代1 - 属性4 @/迭代2 - 属性5 @/迭代3 - 属性all @所有执行 -- 不缓存查询参数,rawMethod 为 contribute,打印所属模块列表。 - - @/ - - 属性1 @~~ - - 属性2 @/模块2 - - 属性3 @~~ - - 属性4 @~~ - - 属性5 @/模块5 -- 不缓存查询参数,rawMethod 为 work,查询参数中 module 不为空。 @1 -- 不缓存查询参数,rawMethod 为 work,查询参数中 queryID 不为空。 @1 -- 不缓存查询参数,rawMethod 为 work,查询参数中 actionURL 不为空。 @1 -- 不缓存查询参数,rawMethod 为 work,查询字段中 closedReason 为空。 @0 -- 不缓存查询参数,rawMethod 为 work,查询字段中 closedBy 为空。 @0 -- 不缓存查询参数,rawMethod 为 work,查询字段中 closedDate 为空。 @0 -- 不缓存查询参数,rawMethod 为 work,查询字段中 canceledBy 为空。 @0 -- 不缓存查询参数,rawMethod 为 work,查询字段中 canceledDate 为空。 @0 -- 不缓存查询参数,rawMethod 为 work,打印 module 的值。属性module @workTask -- 不缓存查询参数,rawMethod 为 work,打印 queryID 的值。属性queryID @1 -- 不缓存查询参数,rawMethod 为 work,打印 actionURL 的值。属性actionURL @/my-work-task.html -- 不缓存查询参数,rawMethod 为 work,打印所属项目列表。 - - 属性1 @项目1 - - 属性2 @项目2 - - 属性all @所有项目 -- 不缓存查询参数,rawMethod 为 work,打印所属执行列表。 - - 属性3 @/迭代1 - - 属性4 @/迭代2 - - 属性5 @/迭代3 - - 属性all @所有执行 -- 不缓存查询参数,rawMethod 为 work,打印所属模块列表。 +- module 为 workTask,不缓存查询参数,打印所属模块列表。 - @/ - 属性1 @~~ - 属性2 @/模块2 - 属性3 @~~ - 属性4 @~~ - 属性5 @/模块5 +- module 为 contributeTask,缓存查询参数,查询参数中 queryID 为空。 @0 +- module 为 contributeTask,缓存查询参数,查询参数中 actionURL 为空。 @0 +- module 为 contributeTask,缓存查询参数,查询字段中 closedReason 不为空。 @1 +- module 为 contributeTask,缓存查询参数,查询字段中 closedBy 不为空。 @1 +- module 为 contributeTask,缓存查询参数,查询字段中 closedDate 不为空。 @1 +- module 为 contributeTask,缓存查询参数,查询字段中 canceledBy 不为空。 @1 +- module 为 contributeTask,缓存查询参数,查询字段中 canceledDate 不为空。 @1 +- module 为 contributeTask,缓存查询参数,打印 module 的值。属性module @task +- module 为 contributeTask,缓存查询参数,打印 queryID 的值。属性queryID @~~ +- module 为 contributeTask,缓存查询参数,打印 actionURL 的值。属性actionURL @~~ +- module 为 contributeTask,缓存查询参数,打印所属项目列表。 + - 属性1 @0 + - 属性2 @0 + - 属性all @0 +- module 为 contributeTask,缓存查询参数,打印所属执行列表。 + - 属性3 @0 + - 属性4 @0 + - 属性5 @0 + - 属性all @0 +- module 为 contributeTask,缓存查询参数,打印所属模块列表。 + - @0 + - 属性1 @0 + - 属性2 @0 + - 属性3 @0 + - 属性4 @0 + - 属性5 @0 */ -$queryID = 1; -$rawMethod = 'contribute'; -$actionURL = "/my-{$rawMethod}-task.html"; -$my = new myTest(); +$my = new myTest(); -$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $rawMethod, true); -r(isset($searchConfig['module'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 module 为空。 -r(isset($searchConfig['queryID'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 queryID 为空。 -r(isset($searchConfig['actionURL'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 actionURL 为空。 -r(isset($searchConfig['fields'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 fields 为空。 -r(isset($searchConfig['params'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 params 为空。 +$queryID = 1; +$module = 'workTask'; +$actionURL = "/my-work-task.html"; +$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $module, true); +r(isset($searchConfig['queryID'])) && p() && e(0); // module 为 workTask,缓存查询参数,查询参数中 queryID 为空。 +r(isset($searchConfig['actionURL'])) && p() && e(0); // module 为 workTask,缓存查询参数,查询参数中 actionURL 为空。 +r(isset($searchConfig['fields']['closedReason'])) && p() && e(1); // module 为 workTask,缓存查询参数,查询字段中 closedReason 不为空。 +r(isset($searchConfig['fields']['closedBy'])) && p() && e(1); // module 为 workTask,缓存查询参数,查询字段中 closedBy 不为空。 +r(isset($searchConfig['fields']['closedDate'])) && p() && e(1); // module 为 workTask,缓存查询参数,查询字段中 closedDate 不为空。 +r(isset($searchConfig['fields']['canceledBy'])) && p() && e(1); // module 为 workTask,缓存查询参数,查询字段中 canceledBy 不为空。 +r(isset($searchConfig['fields']['canceledDate'])) && p() && e(1); // module 为 workTask,缓存查询参数,查询字段中 canceledDate 不为空。 -$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $rawMethod, false); -r(isset($searchConfig['module'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询参数中 module 不为空。 -r(isset($searchConfig['queryID'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询参数中 queryID 不为空。 -r(isset($searchConfig['actionURL'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询参数中 actionURL 不为空。 -r(isset($searchConfig['fields']['closedReason'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedReason 不为空。 -r(isset($searchConfig['fields']['closedBy'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedBy 不为空。 -r(isset($searchConfig['fields']['closedDate'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedDate 不为空。 -r(isset($searchConfig['fields']['canceledBy'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 canceledBy 不为空。 -r(isset($searchConfig['fields']['canceledDate'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 canceledDate 不为空。 +r($searchConfig) && p('module') && e('task'); // module 为 workTask,缓存查询参数,打印 module 的值。 +r($searchConfig) && p('queryID') && e('~~'); // module 为 workTask,缓存查询参数,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('~~'); // module 为 workTask,缓存查询参数,打印 actionURL 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('0,0,0'); // module 为 workTask,缓存查询参数,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('0,0,0,0'); // module 为 workTask,缓存查询参数,打印所属执行列表。 +r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('0,0,0,0,0,0'); // module 为 workTask,缓存查询参数,打印所属模块列表。 -r($searchConfig) && p('module') && e('contributeTask'); // 不缓存查询参数,rawMethod 为 contribute,打印 module 的值。 -r($searchConfig) && p('queryID') && e('1'); // 不缓存查询参数,rawMethod 为 contribute,打印 queryID 的值。 -r($searchConfig) && p('actionURL') && e('/my-contribute-task.html'); // 不缓存查询参数,rawMethod 为 contribute,打印 actionURL 的值。 -r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // 不缓存查询参数,rawMethod 为 contribute,打印所属项目列表。 -r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // 不缓存查询参数,rawMethod 为 contribute,打印所属执行列表。 -r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('/,~~,/模块2,~~,~~,/模块5'); // 不缓存查询参数,rawMethod 为 contribute,打印所属模块列表。 +$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $module, false); +r(isset($searchConfig['queryID'])) && p() && e(1); // module 为 workTask,不缓存查询参数,查询参数中 queryID 不为空。 +r(isset($searchConfig['actionURL'])) && p() && e(1); // module 为 workTask,不缓存查询参数,查询参数中 actionURL 不为空。 +r(isset($searchConfig['fields']['closedReason'])) && p() && e(0); // module 为 workTask,不缓存查询参数,查询字段中 closedReason 为空。 +r(isset($searchConfig['fields']['closedBy'])) && p() && e(0); // module 为 workTask,不缓存查询参数,查询字段中 closedBy 为空。 +r(isset($searchConfig['fields']['closedDate'])) && p() && e(0); // module 为 workTask,不缓存查询参数,查询字段中 closedDate 为空。 +r(isset($searchConfig['fields']['canceledBy'])) && p() && e(0); // module 为 workTask,不缓存查询参数,查询字段中 canceledBy 为空。 +r(isset($searchConfig['fields']['canceledDate'])) && p() && e(0); // module 为 workTask,不缓存查询参数,查询字段中 canceledDate 为空。 -$rawMethod = 'work'; -$actionURL = "/my-{$rawMethod}-task.html"; -$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $rawMethod, false); -r(isset($searchConfig['module'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 work,查询参数中 module 不为空。 -r(isset($searchConfig['queryID'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 work,查询参数中 queryID 不为空。 -r(isset($searchConfig['actionURL'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 work,查询参数中 actionURL 不为空。 -r(isset($searchConfig['fields']['closedReason'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 closedReason 为空。 -r(isset($searchConfig['fields']['closedBy'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 closedBy 为空。 -r(isset($searchConfig['fields']['closedDate'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 closedDate 为空。 -r(isset($searchConfig['fields']['canceledBy'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 canceledBy 为空。 -r(isset($searchConfig['fields']['canceledDate'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 canceledDate 为空。 +r($searchConfig) && p('module') && e('workTask'); // module 为 workTask,不缓存查询参数,打印 module 的值。 +r($searchConfig) && p('queryID') && e('1'); // module 为 workTask,不缓存查询参数,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/my-work-task.html'); // module 为 workTask,不缓存查询参数,打印 actionURL 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // module 为 workTask,不缓存查询参数,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // module 为 workTask,不缓存查询参数,打印所属执行列表。 +r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('/,~~,/模块2,~~,~~,/模块5'); // module 为 workTask,不缓存查询参数,打印所属模块列表。 -r($searchConfig) && p('module') && e('workTask'); // 不缓存查询参数,rawMethod 为 work,打印 module 的值。 -r($searchConfig) && p('queryID') && e('1'); // 不缓存查询参数,rawMethod 为 work,打印 queryID 的值。 -r($searchConfig) && p('actionURL') && e('/my-work-task.html'); // 不缓存查询参数,rawMethod 为 work,打印 actionURL 的值。 -r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // 不缓存查询参数,rawMethod 为 work,打印所属项目列表。 -r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // 不缓存查询参数,rawMethod 为 work,打印所属执行列表。 -r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('/,~~,/模块2,~~,~~,/模块5'); // 不缓存查询参数,rawMethod 为 work,打印所属模块列表。 +$queryID = 1; +$module = 'contributeTask'; +$actionURL = "/my-contribute-task.html"; +$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $module, true); +r(isset($searchConfig['queryID'])) && p() && e(0); // module 为 contributeTask,缓存查询参数,查询参数中 queryID 为空。 +r(isset($searchConfig['actionURL'])) && p() && e(0); // module 为 contributeTask,缓存查询参数,查询参数中 actionURL 为空。 +r(isset($searchConfig['fields']['closedReason'])) && p() && e(1); // module 为 contributeTask,缓存查询参数,查询字段中 closedReason 不为空。 +r(isset($searchConfig['fields']['closedBy'])) && p() && e(1); // module 为 contributeTask,缓存查询参数,查询字段中 closedBy 不为空。 +r(isset($searchConfig['fields']['closedDate'])) && p() && e(1); // module 为 contributeTask,缓存查询参数,查询字段中 closedDate 不为空。 +r(isset($searchConfig['fields']['canceledBy'])) && p() && e(1); // module 为 contributeTask,缓存查询参数,查询字段中 canceledBy 不为空。 +r(isset($searchConfig['fields']['canceledDate'])) && p() && e(1); // module 为 contributeTask,缓存查询参数,查询字段中 canceledDate 不为空。 + +r($searchConfig) && p('module') && e('task'); // module 为 contributeTask,缓存查询参数,打印 module 的值。 +r($searchConfig) && p('queryID') && e('~~'); // module 为 contributeTask,缓存查询参数,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('~~'); // module 为 contributeTask,缓存查询参数,打印 actionURL 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('0,0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属执行列表。 +r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('0,0,0,0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属模块列表。 \ No newline at end of file From 8201c886710e6592142d9ff867675880d1c71aae Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 13:59:56 +0800 Subject: [PATCH 26/32] + [misc] Add unittest steps of the myModel::buildTaskSearchForm method. --- module/my/test/model/buildtasksearchform.php | 46 +++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/module/my/test/model/buildtasksearchform.php b/module/my/test/model/buildtasksearchform.php index 2110f78198..95c080d276 100755 --- a/module/my/test/model/buildtasksearchform.php +++ b/module/my/test/model/buildtasksearchform.php @@ -103,6 +103,33 @@ cid=1 - 属性3 @0 - 属性4 @0 - 属性5 @0 +- 不缓存查询参数,module 为 contributeTask,查询参数中 module 不为空。 @1 +- 不缓存查询参数,module 为 contributeTask,查询参数中 queryID 不为空。 @1 +- 不缓存查询参数,module 为 contributeTask,查询参数中 actionURL 不为空。 @1 +- 不缓存查询参数,module 为 contributeTask,查询字段中 closedReason 不为空。 @1 +- 不缓存查询参数,module 为 contributeTask,查询字段中 closedBy 不为空。 @1 +- 不缓存查询参数,module 为 contributeTask,查询字段中 closedDate 不为空。 @1 +- 不缓存查询参数,module 为 contributeTask,查询字段中 canceledBy 不为空。 @1 +- 不缓存查询参数,module 为 contributeTask,查询字段中 canceledDate 不为空。 @1 +- 不缓存查询参数,module 为 contributeTask,打印 module 的值。属性module @contributeTask +- 不缓存查询参数,module 为 contributeTask,打印 queryID 的值。属性queryID @1 +- 不缓存查询参数,module 为 contributeTask,打印 actionURL 的值。属性actionURL @/my-contribute-task.html +- 不缓存查询参数,module 为 contributeTask,打印所属项目列表。 + - 属性1 @项目1 + - 属性2 @项目2 + - 属性all @所有项目 +- 不缓存查询参数,module 为 contributeTask,打印所属执行列表。 + - 属性3 @/迭代1 + - 属性4 @/迭代2 + - 属性5 @/迭代3 + - 属性all @所有执行 +- 不缓存查询参数,module 为 contributeTask,打印所属模块列表。 + - @/ + - 属性1 @~~ + - 属性2 @/模块2 + - 属性3 @~~ + - 属性4 @~~ + - 属性5 @/模块5 */ @@ -160,4 +187,21 @@ r($searchConfig) && p('queryID') && e('~~') r($searchConfig) && p('actionURL') && e('~~'); // module 为 contributeTask,缓存查询参数,打印 actionURL 的值。 r($searchConfig['params']['project']['values']) && p('1,2,all') && e('0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属项目列表。 r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('0,0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属执行列表。 -r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('0,0,0,0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属模块列表。 \ No newline at end of file +r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('0,0,0,0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属模块列表。 + +$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $module, false); +r(isset($searchConfig['module'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询参数中 module 不为空。 +r(isset($searchConfig['queryID'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询参数中 queryID 不为空。 +r(isset($searchConfig['actionURL'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询参数中 actionURL 不为空。 +r(isset($searchConfig['fields']['closedReason'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询字段中 closedReason 不为空。 +r(isset($searchConfig['fields']['closedBy'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询字段中 closedBy 不为空。 +r(isset($searchConfig['fields']['closedDate'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询字段中 closedDate 不为空。 +r(isset($searchConfig['fields']['canceledBy'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询字段中 canceledBy 不为空。 +r(isset($searchConfig['fields']['canceledDate'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询字段中 canceledDate 不为空。 + +r($searchConfig) && p('module') && e('contributeTask'); // 不缓存查询参数,module 为 contributeTask,打印 module 的值。 +r($searchConfig) && p('queryID') && e('1'); // 不缓存查询参数,module 为 contributeTask,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/my-contribute-task.html'); // 不缓存查询参数,module 为 contributeTask,打印 actionURL 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // 不缓存查询参数,module 为 contributeTask,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // 不缓存查询参数,module 为 contributeTask,打印所属执行列表。 +r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('/,~~,/模块2,~~,~~,/模块5'); // 不缓存查询参数,module 为 contributeTask,打印所属模块列表。 \ No newline at end of file From 76bdb907e457f4c499242e95147b6ed0d11cfa69 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 15:54:01 +0800 Subject: [PATCH 27/32] * [misc] Fix error parameter. --- module/execution/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/execution/model.php b/module/execution/model.php index 61f61b991f..9b7f33bb18 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4208,7 +4208,7 @@ class executionModel extends model elseif($module == 'programplanTask') { unset($searchConfig['fields']['project']); - $executions = $this->loadModel('programplan')->getPairs($projectID, $productID, 'all'); + $executions = $this->loadModel('programplan')->getPairs($executionID, $productID, 'all'); } elseif($module == 'projectTask') { From 95a107bc730e607c0258ab52e5bd810ae651ee13 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 15:55:43 +0800 Subject: [PATCH 28/32] * [misc] Modify unittest script of the executionModel::buildTaskSearchForm method. --- .../test/model/buildtasksearchform.php | 97 +++++++++++-------- 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/module/execution/test/model/buildtasksearchform.php b/module/execution/test/model/buildtasksearchform.php index d88393158f..3af46524e3 100755 --- a/module/execution/test/model/buildtasksearchform.php +++ b/module/execution/test/model/buildtasksearchform.php @@ -4,17 +4,18 @@ include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/lib/execution.unittest.class.php'; $execution = zenData('project'); -$execution->id->range('1-5'); -$execution->name->range('项目1,项目2,迭代1,迭代2,迭代3'); -$execution->type->range('project{2},sprint,stage,kanban'); +$execution->id->range('1-8'); +$execution->name->range('项目1,项目2,迭代1,迭代2,迭代3,阶段1,阶段2,阶段3'); +$execution->type->range('project{2},sprint,stage,kanban,stage{3}'); +$execution->model->range('scrum,waterfall,``{6}'); $execution->status->range('doing'); -$execution->parent->range('0,0,1,1,2'); -$execution->project->range('0,0,1,1,2'); -$execution->grade->range('2{2},1{3}'); -$execution->path->range('1,2,`1,3`,`1,4`,`2,5`')->prefix(',')->postfix(','); +$execution->parent->range('0,0,1{3},2{3}'); +$execution->project->range('0,0,1{3},2{3}'); +$execution->grade->range('2{2},1{6}'); +$execution->path->range('1,2,`1,3`,`1,4`,`1,5`,`2,6`,`2,7`,`2,8`')->prefix(',')->postfix(','); $execution->begin->range('20230102 000000:0')->type('timestamp')->format('YY/MM/DD'); $execution->end->range('20230212 000000:0')->type('timestamp')->format('YY/MM/DD'); -$execution->gen(5); +$execution->gen(8); $task = zenData('task'); $task->id->range('1-10'); @@ -36,6 +37,10 @@ $query->form->range('`a:59:{s:9:"fieldname";s:0:"";s:11:"fieldstatus";s:0:"";s:9 $query->sql->range("`(( 1 AND `name` LIKE '%任务%' ) AND ( 1 )) AND deleted = '0'`"); $query->gen(1); +$module = zenData('module'); +$module->name->range('1,2,3,4,5')->prefix('模块'); +$module->gen(5); + su('admin'); /** @@ -44,48 +49,54 @@ title=测试executionModel->buildTaskSearchForm(); timeout=0 cid=1 -- 传递项目 ID,缓存查询参数,打印 queryID 的值。 @0 -- 传递项目 ID,缓存查询参数,打印 actionURL 的值。 @0 -- 传递项目 ID,缓存查询参数,打印所属执行列表。 @0 -- 传递项目 ID,不缓存查询参数,打印 queryID 的值。属性queryID @1 -- 传递项目 ID,不缓存查询参数,打印 actionURL 的值。属性actionURL @/execution-task-3-bySearch-myQueryID.html -- 传递项目 ID,不缓存查询参数,打印所属执行列表。 - - @~~ +- module 为 projectTask,缓存查询参数,查询参数中 queryID 为空。 @0 +- module 为 projectTask,缓存查询参数,查询参数中 actionURL 为空。 @0 +- module 为 projectTask,缓存查询参数,查询参数中有 project 字段。 @1 +- module 为 projectTask,缓存查询参数,查询参数中有 module 字段。 @1 +- module 为 projectTask,缓存查询参数,打印 module 的值。属性module @task +- module 为 projectTask,缓存查询参数,打印所属执行列表。 + - 属性3 @0 + - 属性4 @0 + - 属性5 @0 +- module 为 projectTask,不缓存查询参数,查询参数中 queryID 有值。 @1 +- module 为 projectTask,不缓存查询参数,查询参数中 actionURL 有值。 @1 +- module 为 projectTask,不缓存查询参数,查询参数中没有 project 字段。 @0 +- module 为 projectTask,不缓存查询参数,查询参数中没有 module 字段。 @0 +- module 为 projectTask,不缓存查询参数,打印 module 的值。属性module @projectTask +- module 为 projectTask,不缓存查询参数,打印 queryID 的值。属性queryID @1 +- module 为 projectTask,不缓存查询参数,打印 actionURL 的值。属性actionURL @/project-execution-bySearch-1-order_desc-0-0-100-1-myQueryID.html +- module 为 projectTask,不缓存查询参数,打印所属执行列表。 - 属性3 @迭代1 - 属性4 @迭代2 - 属性5 @迭代3 -- 传递执行 ID,不缓存查询参数,打印 queryID 的值。属性queryID @1 -- 传递执行 ID,不缓存查询参数,打印 actionURL 的值。属性actionURL @/execution-task-3-bySearch-myQueryID.html -- 传递执行 ID,不缓存查询参数,打印所属执行列表。 - - @~~ - - 属性3 @迭代1 - - 属性4 @~~ - - 属性5 @~~ - - 属性all @所有执行 */ -$projectID = 1; -$productID = 0; -$executionID = 3; -$executions = [3 => '迭代1', 4 => '迭代2', 5 => '迭代3']; -$queryID = 1; -$module = 'task'; -$actionURL = '/execution-task-3-bySearch-myQueryID.html'; - $execution = new executionTest(); +$productID = 0; +$queryID = 1; -$searchConfig = $execution->buildTaskSearchFormTest($projectID, $productID, $executions, $queryID, $actionURL, $module, true); -r(isset($searchConfig['queryID'])) && p() && e(0); // 传递项目 ID,缓存查询参数,打印 queryID 的值。 -r(isset($searchConfig['actionURL'])) && p() && e(0); // 传递项目 ID,缓存查询参数,打印 actionURL 的值。 -r(isset($searchConfig['params']['execution']['values'])) && p() && e(0); // 传递项目 ID,缓存查询参数,打印所属执行列表。 - -$searchConfig = $execution->buildTaskSearchFormTest($projectID, $productID, $executions, $queryID, $actionURL, $module, false); -r($searchConfig) && p('queryID') && e('1'); // 传递项目 ID,不缓存查询参数,打印 queryID 的值。 -r($searchConfig) && p('actionURL') && e('/execution-task-3-bySearch-myQueryID.html'); // 传递项目 ID,不缓存查询参数,打印 actionURL 的值。 -r($searchConfig['params']['execution']['values']) && p(',3,4,5') && e('~~,迭代1,迭代2,迭代3'); // 传递项目 ID,不缓存查询参数,打印所属执行列表。 +/** + * 测试为项目迭代列表页面构造搜索参数功能。 + */ +$executionID = 1; +$executions = [3 => '迭代1', 4 => '迭代2', 5 => '迭代3']; +$actionURL = '/project-execution-bySearch-1-order_desc-0-0-100-1-myQueryID.html'; +$module = 'projectTask'; +$searchConfig = $execution->buildTaskSearchFormTest($executionID, $productID, $executions, $queryID, $actionURL, $module, true); +r(isset($searchConfig['queryID'])) && p() && e(0); // module 为 projectTask,缓存查询参数,查询参数中 queryID 为空。 +r(isset($searchConfig['actionURL'])) && p() && e(0); // module 为 projectTask,缓存查询参数,查询参数中 actionURL 为空。 +r(isset($searchConfig['fields']['project'])) && p() && e(1); // module 为 projectTask,缓存查询参数,查询参数中有 project 字段。 +r(isset($searchConfig['fields']['module'])) && p() && e(1); // module 为 projectTask,缓存查询参数,查询参数中有 module 字段。 +r($searchConfig) && p('module') && e('task'); // module 为 projectTask,缓存查询参数,打印 module 的值。 +r($searchConfig['params']['execution']['values']) && p('3,4,5') && e('0,0,0'); // module 为 projectTask,缓存查询参数,打印所属执行列表。 $searchConfig = $execution->buildTaskSearchFormTest($executionID, $productID, $executions, $queryID, $actionURL, $module, false); -r($searchConfig) && p('queryID') && e('1'); // 传递执行 ID,不缓存查询参数,打印 queryID 的值。 -r($searchConfig) && p('actionURL') && e('/execution-task-3-bySearch-myQueryID.html'); // 传递执行 ID,不缓存查询参数,打印 actionURL 的值。 -r($searchConfig['params']['execution']['values']) && p(',3,4,5,all') && e('~~,迭代1,~~,~~,所有执行'); // 传递执行 ID,不缓存查询参数,打印所属执行列表。 +r(isset($searchConfig['queryID'])) && p() && e(1); // module 为 projectTask,不缓存查询参数,查询参数中 queryID 有值。 +r(isset($searchConfig['actionURL'])) && p() && e(1); // module 为 projectTask,不缓存查询参数,查询参数中 actionURL 有值。 +r(isset($searchConfig['fields']['project'])) && p() && e(0); // module 为 projectTask,不缓存查询参数,查询参数中没有 project 字段。 +r(isset($searchConfig['fields']['module'])) && p() && e(0); // module 为 projectTask,不缓存查询参数,查询参数中没有 module 字段。 +r($searchConfig) && p('module') && e('projectTask'); // module 为 projectTask,不缓存查询参数,打印 module 的值。 +r($searchConfig) && p('queryID') && e('1'); // module 为 projectTask,不缓存查询参数,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/project-execution-bySearch-1-order_desc-0-0-100-1-myQueryID.html'); // module 为 projectTask,不缓存查询参数,打印 actionURL 的值。 +r($searchConfig['params']['execution']['values']) && p('3,4,5') && e('迭代1,迭代2,迭代3'); // module 为 projectTask,不缓存查询参数,打印所属执行列表。 \ No newline at end of file From d65a3498ee63702dfd85f04c304eef675ac638ea Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 15:57:13 +0800 Subject: [PATCH 29/32] + [misc] Add unittest steps of the executionModel::buildTaskSearchForm method. --- .../test/model/buildtasksearchform.php | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/module/execution/test/model/buildtasksearchform.php b/module/execution/test/model/buildtasksearchform.php index 3af46524e3..dff5ab62ba 100755 --- a/module/execution/test/model/buildtasksearchform.php +++ b/module/execution/test/model/buildtasksearchform.php @@ -69,6 +69,24 @@ cid=1 - 属性3 @迭代1 - 属性4 @迭代2 - 属性5 @迭代3 +- module 为 programplanTask,缓存查询参数,查询参数中 queryID 为空。 @0 +- module 为 programplanTask,缓存查询参数,查询参数中 actionURL 为空。 @0 +- module 为 programplanTask,缓存查询参数,查询参数中有 project 字段。 @1 +- module 为 programplanTask,缓存查询参数,打印 module 的值。属性module @task +- module 为 programplanTask,缓存查询参数,打印所属执行列表。 + - 属性6 @0 + - 属性7 @0 + - 属性8 @0 +- module 为 programplanTask,不缓存查询参数,查询参数中 queryID 有值。 @1 +- module 为 programplanTask,不缓存查询参数,查询参数中 actionURL 有值。 @1 +- module 为 programplanTask,不缓存查询参数,查询参数中没有 project 字段。 @0 +- module 为 programplanTask,不缓存查询参数,打印 module 的值。属性module @programplanTask +- module 为 programplanTask,不缓存查询参数,打印 queryID 的值。属性queryID @1 +- module 为 programplanTask,不缓存查询参数,打印 actionURL 的值。属性actionURL @/programplan-browse-2-0-gantt-id_asc-0-bysearch-myQueryID.html +- module 为 programplanTask,不缓存查询参数,打印所属执行列表。 + - 属性6 @/阶段1 + - 属性7 @/阶段2 + - 属性8 @/阶段3 */ @@ -99,4 +117,27 @@ r(isset($searchConfig['fields']['module'])) && p() && e(0); r($searchConfig) && p('module') && e('projectTask'); // module 为 projectTask,不缓存查询参数,打印 module 的值。 r($searchConfig) && p('queryID') && e('1'); // module 为 projectTask,不缓存查询参数,打印 queryID 的值。 r($searchConfig) && p('actionURL') && e('/project-execution-bySearch-1-order_desc-0-0-100-1-myQueryID.html'); // module 为 projectTask,不缓存查询参数,打印 actionURL 的值。 -r($searchConfig['params']['execution']['values']) && p('3,4,5') && e('迭代1,迭代2,迭代3'); // module 为 projectTask,不缓存查询参数,打印所属执行列表。 \ No newline at end of file +r($searchConfig['params']['execution']['values']) && p('3,4,5') && e('迭代1,迭代2,迭代3'); // module 为 projectTask,不缓存查询参数,打印所属执行列表。 + +/** + * 测试为瀑布项目阶段甘特图页面构造搜索参数功能。 + */ +$executionID = 2; +$executions = [3 => '迭代1', 4 => '迭代2', 5 => '迭代3']; +$actionURL = '/programplan-browse-2-0-gantt-id_asc-0-bysearch-myQueryID.html'; +$module = 'programplanTask'; +$searchConfig = $execution->buildTaskSearchFormTest($executionID, $productID, $executions, $queryID, $actionURL, $module, true); +r(isset($searchConfig['queryID'])) && p() && e(0); // module 为 programplanTask,缓存查询参数,查询参数中 queryID 为空。 +r(isset($searchConfig['actionURL'])) && p() && e(0); // module 为 programplanTask,缓存查询参数,查询参数中 actionURL 为空。 +r(isset($searchConfig['fields']['project'])) && p() && e(1); // module 为 programplanTask,缓存查询参数,查询参数中有 project 字段。 +r($searchConfig) && p('module') && e('task'); // module 为 programplanTask,缓存查询参数,打印 module 的值。 +r($searchConfig['params']['execution']['values']) && p('6,7,8') && e('0,0,0'); // module 为 programplanTask,缓存查询参数,打印所属执行列表。 + +$searchConfig = $execution->buildTaskSearchFormTest($executionID, $productID, $executions, $queryID, $actionURL, $module, false); +r(isset($searchConfig['queryID'])) && p() && e(1); // module 为 programplanTask,不缓存查询参数,查询参数中 queryID 有值。 +r(isset($searchConfig['actionURL'])) && p() && e(1); // module 为 programplanTask,不缓存查询参数,查询参数中 actionURL 有值。 +r(isset($searchConfig['fields']['project'])) && p() && e(0); // module 为 programplanTask,不缓存查询参数,查询参数中没有 project 字段。 +r($searchConfig) && p('module') && e('programplanTask'); // module 为 programplanTask,不缓存查询参数,打印 module 的值。 +r($searchConfig) && p('queryID') && e('1'); // module 为 programplanTask,不缓存查询参数,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/programplan-browse-2-0-gantt-id_asc-0-bysearch-myQueryID.html'); // module 为 programplanTask,不缓存查询参数,打印 actionURL 的值。 +r($searchConfig['params']['execution']['values']) && p('6,7,8') && e('/阶段1,/阶段2,/阶段3'); // module 为 programplanTask,不缓存查询参数,打印所属执行列表。 \ No newline at end of file From 0f3567d9a48b8f87644acfcd08c3ceccb393ec5c Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 15:58:02 +0800 Subject: [PATCH 30/32] + [misc] Add unittest steps of the executionModel::buildTaskSearchForm method. --- .../test/model/buildtasksearchform.php | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/module/execution/test/model/buildtasksearchform.php b/module/execution/test/model/buildtasksearchform.php index dff5ab62ba..ddf701e594 100755 --- a/module/execution/test/model/buildtasksearchform.php +++ b/module/execution/test/model/buildtasksearchform.php @@ -87,6 +87,31 @@ cid=1 - 属性6 @/阶段1 - 属性7 @/阶段2 - 属性8 @/阶段3 +- module 为 task,缓存查询参数,查询参数中 queryID 为空。 @0 +- module 为 task,缓存查询参数,查询参数中 actionURL 为空。 @0 +- module 为 task,缓存查询参数,查询参数中 onMenuBar 为空。 @0 +- module 为 task,缓存查询参数,打印所属项目列表。 + - 属性1 @0 + - 属性2 @0 + - 属性all @0 +- module 为 task,缓存查询参数,打印所属执行列表。 + - @0 + - 属性3 @0 + - 属性all @0 +- module 为 task,不缓存查询参数,查询参数中 queryID 有值。 @1 +- module 为 task,不缓存查询参数,查询参数中 actionURL 有值。 @1 +- module 为 task,不缓存查询参数,查询参数中 onMenuBar 有值。 @1 +- module 为 task,不缓存查询参数,打印 module 的值。属性module @task +- module 为 task,不缓存查询参数,打印 queryID 的值。属性queryID @1 +- module 为 task,不缓存查询参数,打印 actionURL 的值。属性actionURL @/execution-task-3-bySearch-myQueryID.html +- module 为 task,不缓存查询参数,打印所属项目列表。 + - 属性1 @项目1 + - 属性2 @项目2 + - 属性all @所有项目 +- module 为 task,不缓存查询参数,打印所属执行列表。 + - @~~ + - 属性3 @迭代1 + - 属性all @所有执行 */ @@ -140,4 +165,28 @@ r(isset($searchConfig['fields']['project'])) && p() && e(0); r($searchConfig) && p('module') && e('programplanTask'); // module 为 programplanTask,不缓存查询参数,打印 module 的值。 r($searchConfig) && p('queryID') && e('1'); // module 为 programplanTask,不缓存查询参数,打印 queryID 的值。 r($searchConfig) && p('actionURL') && e('/programplan-browse-2-0-gantt-id_asc-0-bysearch-myQueryID.html'); // module 为 programplanTask,不缓存查询参数,打印 actionURL 的值。 -r($searchConfig['params']['execution']['values']) && p('6,7,8') && e('/阶段1,/阶段2,/阶段3'); // module 为 programplanTask,不缓存查询参数,打印所属执行列表。 \ No newline at end of file +r($searchConfig['params']['execution']['values']) && p('6,7,8') && e('/阶段1,/阶段2,/阶段3'); // module 为 programplanTask,不缓存查询参数,打印所属执行列表。 + +/** + * 测试为执行任务列表页面构造搜索参数功能。 + */ +$executionID = 3; +$executions = [3 => '迭代1', 4 => '迭代2', 5 => '迭代3']; +$actionURL = '/execution-task-3-bySearch-myQueryID.html'; +$module = 'task'; +$searchConfig = $execution->buildTaskSearchFormTest($executionID, $productID, $executions, $queryID, $actionURL, $module, true); +r(isset($searchConfig['queryID'])) && p() && e(0); // module 为 task,缓存查询参数,查询参数中 queryID 为空。 +r(isset($searchConfig['actionURL'])) && p() && e(0); // module 为 task,缓存查询参数,查询参数中 actionURL 为空。 +r(isset($searchConfig['onMenuBar'])) && p() && e(0); // module 为 task,缓存查询参数,查询参数中 onMenuBar 为空。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('0,0,0'); // module 为 task,缓存查询参数,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p(',3,all') && e('0,0,0'); // module 为 task,缓存查询参数,打印所属执行列表。 + +$searchConfig = $execution->buildTaskSearchFormTest($executionID, $productID, $executions, $queryID, $actionURL, $module, false); +r(isset($searchConfig['queryID'])) && p() && e(1); // module 为 task,不缓存查询参数,查询参数中 queryID 有值。 +r(isset($searchConfig['actionURL'])) && p() && e(1); // module 为 task,不缓存查询参数,查询参数中 actionURL 有值。 +r(isset($searchConfig['onMenuBar'])) && p() && e(1); // module 为 task,不缓存查询参数,查询参数中 onMenuBar 有值。 +r($searchConfig) && p('module') && e('task'); // module 为 task,不缓存查询参数,打印 module 的值。 +r($searchConfig) && p('queryID') && e('1'); // module 为 task,不缓存查询参数,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/execution-task-3-bySearch-myQueryID.html'); // module 为 task,不缓存查询参数,打印 actionURL 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // module 为 task,不缓存查询参数,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p(',3,all') && e('~~,迭代1,所有执行'); // module 为 task,不缓存查询参数,打印所属执行列表。 \ No newline at end of file From a60d2e1ebb5dc2bbfd366631fe457913b3035413 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 16:01:25 +0800 Subject: [PATCH 31/32] * [misc] Simplify unittest steps of the myModel::buildTaskSearchForm method. --- module/my/test/model/buildtasksearchform.php | 60 +++++++------------- 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/module/my/test/model/buildtasksearchform.php b/module/my/test/model/buildtasksearchform.php index 95c080d276..c2680f0085 100755 --- a/module/my/test/model/buildtasksearchform.php +++ b/module/my/test/model/buildtasksearchform.php @@ -33,8 +33,6 @@ cid=1 - module 为 workTask,缓存查询参数,查询字段中 canceledBy 不为空。 @1 - module 为 workTask,缓存查询参数,查询字段中 canceledDate 不为空。 @1 - module 为 workTask,缓存查询参数,打印 module 的值。属性module @task -- module 为 workTask,缓存查询参数,打印 queryID 的值。属性queryID @~~ -- module 为 workTask,缓存查询参数,打印 actionURL 的值。属性actionURL @~~ - module 为 workTask,缓存查询参数,打印所属项目列表。 - 属性1 @0 - 属性2 @0 @@ -46,10 +44,7 @@ cid=1 - 属性all @0 - module 为 workTask,缓存查询参数,打印所属模块列表。 - @0 - - 属性1 @0 - 属性2 @0 - - 属性3 @0 - - 属性4 @0 - 属性5 @0 - module 为 workTask,不缓存查询参数,查询参数中 queryID 不为空。 @1 - module 为 workTask,不缓存查询参数,查询参数中 actionURL 不为空。 @1 @@ -72,10 +67,7 @@ cid=1 - 属性all @所有执行 - module 为 workTask,不缓存查询参数,打印所属模块列表。 - @/ - - 属性1 @~~ - 属性2 @/模块2 - - 属性3 @~~ - - 属性4 @~~ - 属性5 @/模块5 - module 为 contributeTask,缓存查询参数,查询参数中 queryID 为空。 @0 - module 为 contributeTask,缓存查询参数,查询参数中 actionURL 为空。 @0 @@ -85,8 +77,6 @@ cid=1 - module 为 contributeTask,缓存查询参数,查询字段中 canceledBy 不为空。 @1 - module 为 contributeTask,缓存查询参数,查询字段中 canceledDate 不为空。 @1 - module 为 contributeTask,缓存查询参数,打印 module 的值。属性module @task -- module 为 contributeTask,缓存查询参数,打印 queryID 的值。属性queryID @~~ -- module 为 contributeTask,缓存查询参数,打印 actionURL 的值。属性actionURL @~~ - module 为 contributeTask,缓存查询参数,打印所属项目列表。 - 属性1 @0 - 属性2 @0 @@ -98,10 +88,7 @@ cid=1 - 属性all @0 - module 为 contributeTask,缓存查询参数,打印所属模块列表。 - @0 - - 属性1 @0 - 属性2 @0 - - 属性3 @0 - - 属性4 @0 - 属性5 @0 - 不缓存查询参数,module 为 contributeTask,查询参数中 module 不为空。 @1 - 不缓存查询参数,module 为 contributeTask,查询参数中 queryID 不为空。 @1 @@ -125,10 +112,7 @@ cid=1 - 属性all @所有执行 - 不缓存查询参数,module 为 contributeTask,打印所属模块列表。 - @/ - - 属性1 @~~ - 属性2 @/模块2 - - 属性3 @~~ - - 属性4 @~~ - 属性5 @/模块5 */ @@ -147,12 +131,10 @@ r(isset($searchConfig['fields']['closedDate'])) && p() && e(1); // module 为 r(isset($searchConfig['fields']['canceledBy'])) && p() && e(1); // module 为 workTask,缓存查询参数,查询字段中 canceledBy 不为空。 r(isset($searchConfig['fields']['canceledDate'])) && p() && e(1); // module 为 workTask,缓存查询参数,查询字段中 canceledDate 不为空。 -r($searchConfig) && p('module') && e('task'); // module 为 workTask,缓存查询参数,打印 module 的值。 -r($searchConfig) && p('queryID') && e('~~'); // module 为 workTask,缓存查询参数,打印 queryID 的值。 -r($searchConfig) && p('actionURL') && e('~~'); // module 为 workTask,缓存查询参数,打印 actionURL 的值。 -r($searchConfig['params']['project']['values']) && p('1,2,all') && e('0,0,0'); // module 为 workTask,缓存查询参数,打印所属项目列表。 -r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('0,0,0,0'); // module 为 workTask,缓存查询参数,打印所属执行列表。 -r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('0,0,0,0,0,0'); // module 为 workTask,缓存查询参数,打印所属模块列表。 +r($searchConfig) && p('module') && e('task'); // module 为 workTask,缓存查询参数,打印 module 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('0,0,0'); // module 为 workTask,缓存查询参数,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('0,0,0,0'); // module 为 workTask,缓存查询参数,打印所属执行列表。 +r($searchConfig['params']['module']['values']) && p('0,2,5') && e('0,0,0'); // module 为 workTask,缓存查询参数,打印所属模块列表。 $searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $module, false); r(isset($searchConfig['queryID'])) && p() && e(1); // module 为 workTask,不缓存查询参数,查询参数中 queryID 不为空。 @@ -163,12 +145,12 @@ r(isset($searchConfig['fields']['closedDate'])) && p() && e(0); // module 为 r(isset($searchConfig['fields']['canceledBy'])) && p() && e(0); // module 为 workTask,不缓存查询参数,查询字段中 canceledBy 为空。 r(isset($searchConfig['fields']['canceledDate'])) && p() && e(0); // module 为 workTask,不缓存查询参数,查询字段中 canceledDate 为空。 -r($searchConfig) && p('module') && e('workTask'); // module 为 workTask,不缓存查询参数,打印 module 的值。 -r($searchConfig) && p('queryID') && e('1'); // module 为 workTask,不缓存查询参数,打印 queryID 的值。 -r($searchConfig) && p('actionURL') && e('/my-work-task.html'); // module 为 workTask,不缓存查询参数,打印 actionURL 的值。 -r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // module 为 workTask,不缓存查询参数,打印所属项目列表。 -r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // module 为 workTask,不缓存查询参数,打印所属执行列表。 -r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('/,~~,/模块2,~~,~~,/模块5'); // module 为 workTask,不缓存查询参数,打印所属模块列表。 +r($searchConfig) && p('module') && e('workTask'); // module 为 workTask,不缓存查询参数,打印 module 的值。 +r($searchConfig) && p('queryID') && e('1'); // module 为 workTask,不缓存查询参数,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/my-work-task.html'); // module 为 workTask,不缓存查询参数,打印 actionURL 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // module 为 workTask,不缓存查询参数,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // module 为 workTask,不缓存查询参数,打印所属执行列表。 +r($searchConfig['params']['module']['values']) && p('0,2,5') && e('/,/模块2,/模块5'); // module 为 workTask,不缓存查询参数,打印所属模块列表。 $queryID = 1; $module = 'contributeTask'; @@ -182,12 +164,10 @@ r(isset($searchConfig['fields']['closedDate'])) && p() && e(1); // module 为 r(isset($searchConfig['fields']['canceledBy'])) && p() && e(1); // module 为 contributeTask,缓存查询参数,查询字段中 canceledBy 不为空。 r(isset($searchConfig['fields']['canceledDate'])) && p() && e(1); // module 为 contributeTask,缓存查询参数,查询字段中 canceledDate 不为空。 -r($searchConfig) && p('module') && e('task'); // module 为 contributeTask,缓存查询参数,打印 module 的值。 -r($searchConfig) && p('queryID') && e('~~'); // module 为 contributeTask,缓存查询参数,打印 queryID 的值。 -r($searchConfig) && p('actionURL') && e('~~'); // module 为 contributeTask,缓存查询参数,打印 actionURL 的值。 -r($searchConfig['params']['project']['values']) && p('1,2,all') && e('0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属项目列表。 -r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('0,0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属执行列表。 -r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('0,0,0,0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属模块列表。 +r($searchConfig) && p('module') && e('task'); // module 为 contributeTask,缓存查询参数,打印 module 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('0,0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属执行列表。 +r($searchConfig['params']['module']['values']) && p('0,2,5') && e('0,0,0'); // module 为 contributeTask,缓存查询参数,打印所属模块列表。 $searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $module, false); r(isset($searchConfig['module'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询参数中 module 不为空。 @@ -199,9 +179,9 @@ r(isset($searchConfig['fields']['closedDate'])) && p() && e(1); // 不缓存 r(isset($searchConfig['fields']['canceledBy'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询字段中 canceledBy 不为空。 r(isset($searchConfig['fields']['canceledDate'])) && p() && e(1); // 不缓存查询参数,module 为 contributeTask,查询字段中 canceledDate 不为空。 -r($searchConfig) && p('module') && e('contributeTask'); // 不缓存查询参数,module 为 contributeTask,打印 module 的值。 -r($searchConfig) && p('queryID') && e('1'); // 不缓存查询参数,module 为 contributeTask,打印 queryID 的值。 -r($searchConfig) && p('actionURL') && e('/my-contribute-task.html'); // 不缓存查询参数,module 为 contributeTask,打印 actionURL 的值。 -r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // 不缓存查询参数,module 为 contributeTask,打印所属项目列表。 -r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // 不缓存查询参数,module 为 contributeTask,打印所属执行列表。 -r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('/,~~,/模块2,~~,~~,/模块5'); // 不缓存查询参数,module 为 contributeTask,打印所属模块列表。 \ No newline at end of file +r($searchConfig) && p('module') && e('contributeTask'); // 不缓存查询参数,module 为 contributeTask,打印 module 的值。 +r($searchConfig) && p('queryID') && e('1'); // 不缓存查询参数,module 为 contributeTask,打印 queryID 的值。 +r($searchConfig) && p('actionURL') && e('/my-contribute-task.html'); // 不缓存查询参数,module 为 contributeTask,打印 actionURL 的值。 +r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // 不缓存查询参数,module 为 contributeTask,打印所属项目列表。 +r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // 不缓存查询参数,module 为 contributeTask,打印所属执行列表。 +r($searchConfig['params']['module']['values']) && p('0,2,5') && e('/,/模块2,/模块5'); // 不缓存查询参数,module 为 contributeTask,打印所属模块列表。 \ No newline at end of file From ea4f98c66f6564c6312a7b96052a989d1c3b232b Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 16:24:23 +0800 Subject: [PATCH 32/32] * [perf] Refactor search parameter caching: rename cacheSearchParams to cacheSearchFunc - Rename method cacheSearchParams() to cacheSearchFunc() in framework/model.class.php - Update parameter name from cacheSearchParams to cacheSearchFunc across execution and my modules - Update corresponding test files and documentation comments - Improve naming clarity to reflect that we're caching the function/method rather than just parameters --- framework/model.class.php | 6 +++--- module/execution/model.php | 8 ++++---- module/execution/test/lib/execution.unittest.class.php | 6 +++--- module/my/model.php | 8 ++++---- module/my/test/lib/my.unittest.class.php | 8 ++++---- module/search/model.php | 6 +++--- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/framework/model.class.php b/framework/model.class.php index 8832fb0ad8..5d293a32c3 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -283,8 +283,8 @@ class model extends baseModel } /** - * 缓存基础搜索参数。 - * Cache basic search params. + * 缓存用于构造搜索参数的方法和参数。 + * Cache the method and arguments used to build search parameters. * * @param string $module * @param string $classMethod 构造搜索参数的类名和方法名,以::分隔。The class name and method name which builds the search params, separated by ::. @@ -292,7 +292,7 @@ class model extends baseModel * @access public * @return void */ - public function cacheSearchParams(string $module, string $classMethod, array $methodArgs) + public function cacheSearchFunc(string $module, string $classMethod, array $methodArgs) { list($className, $methodName) = explode('::', $classMethod); diff --git a/module/execution/model.php b/module/execution/model.php index 9b7f33bb18..745de2984a 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4173,16 +4173,16 @@ class executionModel extends model * @param array $executions * @param int $queryID * @param string $actionURL - * @param bool $cacheSearchParams 是否缓存搜索参数。默认缓存可以提高性能,构造搜索表单时再加载真实值。 + * @param bool $cacheSearchFunc 是否缓存构造搜索参数的方法。默认缓存可以提高性能,构造搜索表单时再加载真实值。 * @access public * @return void */ - public function buildTaskSearchForm(int $executionID, int $productID, array $executions, int $queryID, string $actionURL, string $module = 'task', bool $cacheSearchParams = true) + public function buildTaskSearchForm(int $executionID, int $productID, array $executions, int $queryID, string $actionURL, string $module = 'task', bool $cacheSearchFunc = true) { $searchConfig = $this->config->execution->search; - if($cacheSearchParams) + if($cacheSearchFunc) { - $this->cacheSearchParams($module, __METHOD__, func_get_args()); + $this->cacheSearchFunc($module, __METHOD__, func_get_args()); return $searchConfig; } diff --git a/module/execution/test/lib/execution.unittest.class.php b/module/execution/test/lib/execution.unittest.class.php index 9a7e18a88c..9325d6e881 100644 --- a/module/execution/test/lib/execution.unittest.class.php +++ b/module/execution/test/lib/execution.unittest.class.php @@ -2486,13 +2486,13 @@ class executionTest * @param int $queryID * @param string $actionURL * @param string $module - * @param bool $cacheSearchParams + * @param bool $cacheSearchFunc * @access public * @return array */ - public function buildTaskSearchFormTest($executionID, $productID, $executions, $queryID, $actionURL, $module, $cacheSearchParams) + public function buildTaskSearchFormTest($executionID, $productID, $executions, $queryID, $actionURL, $module, $cacheSearchFunc): array { - return $this->executionModel->buildTaskSearchForm($executionID, $productID, $executions, $queryID, $actionURL, $module, $cacheSearchParams); + return $this->executionModel->buildTaskSearchForm($executionID, $productID, $executions, $queryID, $actionURL, $module, $cacheSearchFunc); } /** diff --git a/module/my/model.php b/module/my/model.php index 86e7a56af5..43899ebe6c 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -449,17 +449,17 @@ class myModel extends model * @param int $queryID * @param string $actionURL * @param string $module - * @param bool $cacheSearchParams 是否缓存搜索参数。默认缓存可以提高性能,构造搜索表单时再加载真实值。 + * @param bool $cacheSearchFunc 是否缓存构造搜索参数的方法。默认缓存可以提高性能,构造搜索表单时再加载真实值。 * @access public * @return void */ - public function buildTaskSearchForm(int $queryID, string $actionURL, string $module, bool $cacheSearchParams = true) + public function buildTaskSearchForm(int $queryID, string $actionURL, string $module, bool $cacheSearchFunc = true) { $this->loadModel('execution'); $searchConfig = $this->config->execution->search; - if($cacheSearchParams) + if($cacheSearchFunc) { - $this->cacheSearchParams($module, __METHOD__, func_get_args()); + $this->cacheSearchFunc($module, __METHOD__, func_get_args()); return $searchConfig; } diff --git a/module/my/test/lib/my.unittest.class.php b/module/my/test/lib/my.unittest.class.php index d7fcf5d333..bf2a307729 100644 --- a/module/my/test/lib/my.unittest.class.php +++ b/module/my/test/lib/my.unittest.class.php @@ -270,13 +270,13 @@ class myTest * @param int $queryID * @param string $actionURL * @param string $module - * @param bool $cacheSearchParams + * @param bool $cacheSearchFunc * @access public - * @return null|array + * @return array */ - public function buildTaskSearchFormTest(int $queryID, string $actionURL, string $module, bool $cacheSearchParams): null|array + public function buildTaskSearchFormTest(int $queryID, string $actionURL, string $module, bool $cacheSearchFunc): array { - return $this->objectModel->buildTaskSearchForm($queryID, $actionURL, $module, $cacheSearchParams); + return $this->objectModel->buildTaskSearchForm($queryID, $actionURL, $module, $cacheSearchFunc); } /** diff --git a/module/search/model.php b/module/search/model.php index 675eb7ed4e..4c1faf785b 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -18,11 +18,11 @@ class searchModel extends model * Call the method of the searched module to process search parameters when constructing the search form. * * @param string $module - * @param bool @cacheSearchParams // 是否缓存搜索参数。默认不缓存以加载真实值。Whether to cache search parameters. Default is not to cache to load real values. + * @param bool $cacheSearchFunc // 是否缓存构造搜索参数的方法。默认不缓存以加载真实值。Wheater to cache the method of constructing search parameters. Default is not to cache to load real values. * @access public * @return array */ - public function processSearchParams(string $module, bool $cacheSearchParams = false): array + public function processSearchParams(string $module, bool $cacheSearchFunc = false): array { $cacheKey = $module . 'SearchFunc'; $funcModel = $this->session->$cacheKey['funcModel'] ?? ''; @@ -30,7 +30,7 @@ class searchModel extends model $funcArgs = $this->session->$cacheKey['funcArgs'] ?? []; if(!$funcModel || !$funcName || !$funcArgs) return $this->session->{$module . 'searchParams'} ?? []; - $funcArgs['cacheSearchParams'] = $cacheSearchParams; + $funcArgs['cacheSearchFunc'] = $cacheSearchFunc; return $this->loadModel($funcModel)->$funcName(...$funcArgs); }