From d799091b6ad0fbcb87e129627a2c16e508a2d234 Mon Sep 17 00:00:00 2001 From: Lufei Date: Wed, 7 Jun 2023 11:05:52 +0800 Subject: [PATCH 1/7] * If _nocache or http_x_zt_refresh exist, no cache. --- config/filter.php | 1 + framework/base/router.class.php | 2 +- module/block/js/dashboard.js | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/filter.php b/config/filter.php index 5c651142b1..c1d66224d4 100755 --- a/config/filter.php +++ b/config/filter.php @@ -21,6 +21,7 @@ $filter->default->paramValue = 'reg::paramValue'; $filter->default->get['onlybody'] = 'equal::yes'; $filter->default->get['_single'] = 'equal::1'; +$filter->default->get['_nocache'] = 'equal::1'; $filter->default->get['tid'] = 'reg::word'; $filter->default->get['HTTP_X_REQUESTED_WITH'] = 'equal::XMLHttpRequest'; diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 5799fba03f..dcafc52d19 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -2266,7 +2266,7 @@ class baseRouter { $cacheEnable = $this->config->cache->enableFullPage; /* If caching is not turned on, pages that do not need to be cached, or when searching, they are not cached. */ - if(!$cacheEnable || !in_array("{$this->moduleName}|{$this->methodName}", $this->config->cache->fullPages) || stripos($this->server->request_uri, 'search') !== false) + if(!$cacheEnable || !in_array("{$this->moduleName}|{$this->methodName}", $this->config->cache->fullPages) || stripos($this->server->request_uri, 'search') !== false || isset($_GET['_nocache']) || $this->server->http_x_zt_refresh) { $this->loadModule(); return helper::removeUTF8Bom(ob_get_clean()); diff --git a/module/block/js/dashboard.js b/module/block/js/dashboard.js index 63f476ff44..4cea7405c6 100644 --- a/module/block/js/dashboard.js +++ b/module/block/js/dashboard.js @@ -58,14 +58,17 @@ function resizeBlock(blockID, width, callback) * * @param object $panel * @param function afterRefresh + * @param number forceRefresh * @access public * @return void */ -function refreshBlock($panel, afterRefresh) +function refreshBlock($panel, afterRefresh, forceRefresh = 0) { var url = $panel.data('url'); + var headers = {}; + if(forceRefresh) headers['X-Zt-Refresh'] = forceRefresh; $panel.addClass('load-indicator loading'); - $.ajax({url: url, dataType: 'html'}).done(function(data) + $.ajax({url: url, dataType: 'html', headers: headers}).done(function(data) { var $data = $(data); if($data.hasClass('panel')) $panel.empty().append($data.children()); @@ -284,7 +287,7 @@ $(function() always: function(){sortMessager.isShow && sortMessager.hide();} }).on('click', '.refresh-panel', function() { - refreshBlock($(this).closest('.panel')); + refreshBlock($(this).closest('.panel'), null, 1); }); }); From 206b5d737b64c583798d64897f204c657f8bf39b Mon Sep 17 00:00:00 2001 From: Lufei Date: Wed, 7 Jun 2023 11:22:17 +0800 Subject: [PATCH 2/7] + 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); } From 4921d93d3ef9a24c3cbf311ad085c283a3176966 Mon Sep 17 00:00:00 2001 From: Lufei Date: Wed, 7 Jun 2023 13:24:21 +0800 Subject: [PATCH 3/7] * Fix end(): Calling end() on an object is deprecated. --- lib/base/front/front.class.php | 2 +- module/index/control.php | 2 +- module/index/view/index.html.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/base/front/front.class.php b/lib/base/front/front.class.php index 0c00d47a97..4dee58782e 100644 --- a/lib/base/front/front.class.php +++ b/lib/base/front/front.class.php @@ -1259,7 +1259,7 @@ EOT; * Set js value. * * @param string $key - * @param mix $value + * @param mixed $value * @static * @access public * @return string diff --git a/module/index/control.php b/module/index/control.php index b4f6cef1e2..1d89e23cd5 100644 --- a/module/index/control.php +++ b/module/index/control.php @@ -37,7 +37,7 @@ class index extends control if($this->get->open) $open = $this->get->open; $latestVersionList = array(); - if(isset($this->config->global->latestVersionList)) $latestVersionList = json_decode($this->config->global->latestVersionList); + if(isset($this->config->global->latestVersionList)) $latestVersionList = json_decode($this->config->global->latestVersionList, true); $this->view->title = $this->lang->index->common; $this->view->open = helper::safe64Decode($open); diff --git a/module/index/view/index.html.php b/module/index/view/index.html.php index e67c0e8787..b1239b9066 100644 --- a/module/index/view/index.html.php +++ b/module/index/view/index.html.php @@ -133,15 +133,15 @@ js::set('isIntranet', helper::isIntranet()); - name != $lastVersion->name):?> +
From f7ce6e454180f8ab824981b2f4a68582c1925aae Mon Sep 17 00:00:00 2001 From: Lufei Date: Wed, 7 Jun 2023 13:28:46 +0800 Subject: [PATCH 4/7] * Support output xhprof for send. --- framework/base/control.class.php | 1 + framework/base/router.class.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/base/control.class.php b/framework/base/control.class.php index 55ff21c026..ef66f235bc 100644 --- a/framework/base/control.class.php +++ b/framework/base/control.class.php @@ -955,6 +955,7 @@ class baseControl for($i = 0; $i < $obLevel; $i++) ob_end_clean(); $response = helper::removeUTF8Bom(urldecode(json_encode($data))); + $this->app->outputXhprof(); die($response); } diff --git a/framework/base/router.class.php b/framework/base/router.class.php index dcafc52d19..f79c1a63a0 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -718,7 +718,7 @@ class baseRouter * * @return bool */ - protected function outputXhprof() + public function outputXhprof() { if(empty($this->config->debug) || $this->config->debug < 4 || !extension_loaded('xhprof')) return false; From 6a198fb75c419adb13989cde0c7079900a6afdf7 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Wed, 7 Jun 2023 15:54:03 +0800 Subject: [PATCH 5/7] * Compatible screen json. --- lib/dbh/dbh.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dbh/dbh.class.php b/lib/dbh/dbh.class.php index 25335a4ffe..655b527e19 100644 --- a/lib/dbh/dbh.class.php +++ b/lib/dbh/dbh.class.php @@ -255,7 +255,8 @@ class dbh public function formatDmSQL($sql) { $sql = trim($sql); - $sql = str_replace(array('\r', '\n'), ' ', $sql); + /* '\\\\n' try to compatible screen json like \u0232\\nBug. */ + $sql = str_replace(array('\\\\n', '\r', '\n'), ' ', $sql); $sql = $this->formatFunction($sql); $actionPos = strpos($sql, ' '); From 76307011c658860d938553c73a1711ede2737261 Mon Sep 17 00:00:00 2001 From: Lufei Date: Wed, 7 Jun 2023 16:46:10 +0800 Subject: [PATCH 6/7] * Change fail to ignore for ajaxSetZentaoData. --- module/admin/control.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/admin/control.php b/module/admin/control.php index 3cea1d7d4a..7705fca59f 100755 --- a/module/admin/control.php +++ b/module/admin/control.php @@ -81,7 +81,7 @@ class admin extends control */ public function ajaxSetZentaoData() { - if(helper::isIntranet()) return $this->send(array('result' => 'fail')); + if(helper::isIntranet()) return $this->send(array('result' => 'ignore')); $hasInternet = $this->admin->checkInternet(); From e157770ed0bfb062210cf19c22e9669a64d36aa9 Mon Sep 17 00:00:00 2001 From: Lufei Date: Wed, 7 Jun 2023 16:50:37 +0800 Subject: [PATCH 7/7] + Add cache for execution ajaxGetDropMenu. --- module/execution/control.php | 43 +++++++++++++++++++++++++++--------- module/execution/model.php | 2 +- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 7874a3750b..aefc876ced 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -3819,13 +3819,34 @@ class execution extends control * @param int $executionID * @param string $module * @param string $method - * @param mix $extra + * @param mixed $extra * @access public * @return void */ public function ajaxGetDropMenu($executionID, $module, $method, $extra) { - $orderedExecutions = array(); + $this->view->link = $this->execution->getLink($module, $method, $extra); + $this->view->module = $module; + $this->view->method = $method; + $this->view->executionID = $executionID; + $this->view->extra = $extra; + + $cacheProjectsKey = 'execution|dropmenu|project'; + $cacheExecutionsKey = 'execution|dropmenu|executions'; + + if(helper::isCacheEnabled()) + { + $projects = $this->cache->get($cacheProjectsKey); + $projectExecutions = $this->cache->get($cacheExecutionsKey); + + if(!empty($projects) && !empty($projectExecutions)) + { + $this->view->projects = $projects; + $this->view->projectExecutions = $projectExecutions; + $this->display(); + return; + } + } $projects = $this->loadModel('program')->getProjectList(0, 'all', 0, 'order_asc', null, 0, 0, true); $executionGroups = $this->dao->select('*')->from(TABLE_EXECUTION) @@ -3842,7 +3863,8 @@ class execution extends control ->andWhere('type')->eq('execution') ->fetchGroup('root', 'account'); - $projectPairs = array(); + $projectPairs = array(); + $orderedExecutions = array(); foreach($projects as $project) { $executions = zget($executionGroups, $project->id, array()); @@ -3878,13 +3900,14 @@ class execution extends control $projectExecutions[$execution->project][] = $execution; } - $this->view->link = $this->execution->getLink($module, $method, $extra); - $this->view->module = $module; - $this->view->method = $method; - $this->view->executionID = $executionID; - $this->view->extra = $extra; - $this->view->projects = $projectPairs; - $this->view->projectExecutions = $projectExecutions; + if($this->config->cache->enable) + { + $this->cache->set($cacheProjectsKey, $projectPairs); + $this->cache->set($cacheExecutionsKey, $projectExecutions); + } + + $this->view->projects = $projectPairs; + $this->view->projectExecutions = $projectExecutions; $this->display(); } diff --git a/module/execution/model.php b/module/execution/model.php index bc7e4ca317..70a0548461 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2297,7 +2297,7 @@ class executionModel extends model } /** - * Get full name of executons. + * Get full name of executions. * @param array $executions * @access public * @return array