From 3ef2691fd45ffaccad8ad85e2fb31bb7a7f7ac7c Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 18 Aug 2025 11:09:22 +0800 Subject: [PATCH] * [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';