From bc43a5a0537cba1fda1786c0be7bfd771a6cf1bf Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 09:25:19 +0800 Subject: [PATCH] * [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.