From 206b5d737b64c583798d64897f204c657f8bf39b Mon Sep 17 00:00:00 2001 From: Lufei Date: Wed, 7 Jun 2023 11:22:17 +0800 Subject: [PATCH] + Add helper::isCacheEnabled method. --- framework/helper.class.php | 16 ++++++++++++++++ module/block/control.php | 8 ++++---- module/bug/control.php | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/framework/helper.class.php b/framework/helper.class.php index 6ed7d08873..737b31b5e9 100644 --- a/framework/helper.class.php +++ b/framework/helper.class.php @@ -350,12 +350,28 @@ class helper extends baseHelper } /** + * 是否是内网。 + * Check is intranet. + * * @return bool */ public static function isIntranet() { return !defined('USE_INTRANET') ? false : USE_INTRANET; } + + /** + * 检查是否启用缓存。 + * Check is enable cache. + * + * @return bool + */ + public static function isCacheEnabled() + { + if(isset($_GET['_nocace']) || isset($_SERVER['HTTP_X_ZT_REFRESH'])) return false; + global $config; + return $config->cache->enable; + } } /** diff --git a/module/block/control.php b/module/block/control.php index f831400eef..46d2d24136 100755 --- a/module/block/control.php +++ b/module/block/control.php @@ -381,7 +381,7 @@ class block extends control $this->view->tutorialed = $this->loadModel('tutorial')->getTutorialed(); $cacheKey = 'welcomeBlockData'; - if($this->config->cache->enable and $this->cache->has($cacheKey)) + if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $data = $this->cache->get($cacheKey); } @@ -418,7 +418,7 @@ class block extends control */ public function contribute() { - if($this->config->cache->enable && $this->cache->has('contributeBlockData')) + if(helper::isCacheEnabled() && $this->cache->has('contributeBlockData')) { $data = $this->cache->get('contributeBlockData'); } @@ -984,7 +984,7 @@ class block extends control } $cacheKey = __FUNCTION__ . $status . $count . $excludedModel; - if($this->config->cache->enable and $this->cache->has($cacheKey)) + if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $projects = $this->cache->get($cacheKey); } @@ -2037,7 +2037,7 @@ class block extends control $this->app->loadClass('pager', $static = true); $pager = new pager(0, 3, 1); $cacheKey = __FUNCTION__; - if($this->config->cache->enable and $this->cache->has($cacheKey)) + if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $this->app->loadLang('project'); $projects = $this->cache->get($cacheKey); diff --git a/module/bug/control.php b/module/bug/control.php index 0041c667f4..bd318c6270 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -166,7 +166,7 @@ class bug extends control /* Get executions. */ $cacheKey = "bugBrowse{$this->projectID}"; - if($this->config->cache->enable && $this->cache->has($cacheKey)) + if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $executions = $this->cache->get($cacheKey); }