From 48c357a607357866dd170467ca76a6b53ce440f1 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 2 Feb 2021 16:18:19 +0900 Subject: [PATCH] Fix 1596 don't use cache for mid list if there are arguments --- modules/module/module.model.php | 34 +++++++++++++++------------ modules/module/queries/getMidList.xml | 1 - 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/modules/module/module.model.php b/modules/module/module.model.php index 47998f42b..1df2d55c2 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -534,25 +534,29 @@ class moduleModel extends module */ public static function getMidList($args = null, $columnList = array()) { - $list = Rhymix\Framework\Cache::get('site_and_module:module:mid_list'); + // Remove site_srl. + if (is_object($args) && isset($args->site_srl)) + { + unset($args->site_srl); + } + + // Check if there are any arguments. + $argsCount = $args === null ? 0 : countobj($args); + if(!$argsCount) + { + $columnList = array(); + } + + // Use cache only if there are no arguments. Otherwise, get data from DB. + $list = $argsCount ? null : Rhymix\Framework\Cache::get('site_and_module:module:mid_list'); if($list === null) { - if (is_object($args) && isset($args->site_srl)) - { - unset($args->site_srl); - } - - $argsCount = countobj($args); - if(!$argsCount) - { - $columnList = array(); - } - - $output = executeQuery('module.getMidList', $args, $columnList); + $output = executeQueryArray('module.getMidList', $args, $columnList); if(!$output->toBool()) return $output; $list = $output->data; - - if(!$argsCount && !$columnList) + + // Set cache only if there are no arguments. + if(!$argsCount) { Rhymix\Framework\Cache::set('site_and_module:module:mid_list', $list, 0, true); } diff --git a/modules/module/queries/getMidList.xml b/modules/module/queries/getMidList.xml index 2d2e3ddb8..c4c3e92fd 100644 --- a/modules/module/queries/getMidList.xml +++ b/modules/module/queries/getMidList.xml @@ -8,7 +8,6 @@ -