+ Add helper::isCacheEnabled method.

This commit is contained in:
Lufei
2023-06-07 11:22:17 +08:00
parent d799091b6a
commit 206b5d737b
3 changed files with 21 additions and 5 deletions
+16
View File
@@ -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;
}
}
/**
+4 -4
View File
@@ -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);
+1 -1
View File
@@ -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);
}