From cf5fbd878f1e8f351d810210959c2ccfad3411c3 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 11 Jun 2024 16:49:15 +0800 Subject: [PATCH 1/2] * [perf bug #50860] ignore fetch flow when upgrade or install. --- framework/control.class.php | 6 ++++++ framework/model.class.php | 7 +++++++ lib/zin/wg/detail/v1.php | 4 ++-- lib/zin/wg/dtable/v1.php | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/framework/control.class.php b/framework/control.class.php index 44aee1781b..11d53f19d4 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -455,6 +455,7 @@ class control extends baseControl public function getFlowExportFields() { if($this->config->edition == 'open') return array(); + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return array(); $moduleName = $this->moduleName; return $this->$moduleName->getFlowExportFields(); @@ -479,6 +480,7 @@ class control extends baseControl public function printExtendFields(object|string $object, string $type, string $extras = '', bool $print = true, string $moduleName = '', string $methodName = '') { if($this->config->edition == 'open') return false; + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return false; $moduleName = $moduleName ?: $this->app->getModuleName(); $methodName = $methodName ?: $this->app->getMethodName(); @@ -515,6 +517,7 @@ class control extends baseControl public function appendExtendFields(zin\fieldList $fields, string $moduleName = '', string $methodName = ''): zin\fieldList { if($this->config->edition == 'open') return $fields; + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return $fields; $moduleName = $moduleName ? $moduleName : $this->app->getModuleName(); $methodName = $methodName ? $moduleName : $this->app->getMethodName(); @@ -541,6 +544,7 @@ class control extends baseControl public function appendExtendCssAndJS(string $moduleName = '', string $methodName = ''): string { if($this->config->edition == 'open') return ''; + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return ''; $moduleName = $moduleName ? $moduleName : $this->app->getModuleName(); $methodName = $methodName ? $methodName : $this->app->getMethodName(); @@ -579,6 +583,7 @@ class control extends baseControl public function appendExtendForm(string $position = 'info', object $object = null, string $moduleName = '', string $methodName = ''): array { if($this->config->edition == 'open') return array(); + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return array(); $moduleName = $moduleName ? $moduleName : $this->app->getModuleName(); $methodName = $methodName ? $moduleName : $this->app->getMethodName(); @@ -679,6 +684,7 @@ class control extends baseControl public function checkRequireFlowField() { if($this->config->edition == 'open') return false; + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return false; if(empty($_POST)) return false; $action = $this->dao->select('*')->from(TABLE_WORKFLOWACTION)->where('module')->eq($this->moduleName)->andWhere('action')->eq($this->methodName)->fetch(); diff --git a/framework/model.class.php b/framework/model.class.php index 62d8f1b480..f935518644 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -212,6 +212,7 @@ class model extends baseModel public function buildFlowMenu($module, $data, $type = 'browse', $show = '') { if($this->config->edition == 'open') return ''; + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return ''; $moduleName = $module; if(str_contains($module, '.')) [$appName, $moduleName] = explode('.', $module); @@ -304,6 +305,7 @@ class model extends baseModel public function processExportData($data) { if($this->config->edition == 'open') return $data; + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return $data; return $this->loadModel('workflowfield')->processExportData($data); } @@ -318,6 +320,7 @@ class model extends baseModel public function processExportOptions($data) { if($this->config->edition == 'open') return $data; + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return $data; return $this->loadModel('workflowfield')->processExportOptions($data); } @@ -332,6 +335,7 @@ class model extends baseModel public function processImportData($data) { if($this->config->edition == 'open') return $data; + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return $data; return $this->loadModel('workflowfield')->processImportData($data); } @@ -345,6 +349,7 @@ class model extends baseModel public function getFlowExtendFields() { if($this->config->edition == 'open') return array(); + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return array(); return $this->loadModel('flow')->getExtendFields($this->app->getModuleName(), $this->app->getMethodName()); } @@ -358,6 +363,7 @@ class model extends baseModel public function getFlowExportFields() { if($this->config->edition == 'open') return array(); + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return array(); return $this->loadModel('workflowfield')->getExportFields($this->app->getModuleName()); } @@ -372,6 +378,7 @@ class model extends baseModel public function executeHooks(int $objectID): string { if($this->config->edition == 'open') return ''; + if(!empty($this->app->installing) || !empty($this->app->upgrading)) return ''; $moduleName = $this->app->getModuleName(); $methodName = $this->app->getMethodName(); diff --git a/lib/zin/wg/detail/v1.php b/lib/zin/wg/detail/v1.php index 85f5a5942d..773e12529d 100644 --- a/lib/zin/wg/detail/v1.php +++ b/lib/zin/wg/detail/v1.php @@ -282,7 +282,7 @@ CSS; { global $app, $config; $sections = $this->prop('sections'); - if($config->edition != 'open') $sections = $app->control->loadModel('flow')->buildExtendZinValue($sections, $this->prop('object'), 'info'); + if($config->edition != 'open' && empty($app->installing) && empty($app->upgrading)) $sections = $app->control->loadModel('flow')->buildExtendZinValue($sections, $this->prop('object'), 'info'); $list = array(); foreach($sections as $key => $item) @@ -399,7 +399,7 @@ CSS; { global $app, $config; $tabs = $this->prop('tabs'); - if($config->edition != 'open') $tabs = $app->control->loadModel('flow')->buildExtendZinValue($tabs, $this->prop('object'), 'basic'); + if($config->edition != 'open' && empty($app->installing) && empty($app->upgrading)) $tabs = $app->control->loadModel('flow')->buildExtendZinValue($tabs, $this->prop('object'), 'basic'); if(!$tabs) return null; $groups = array(); diff --git a/lib/zin/wg/dtable/v1.php b/lib/zin/wg/dtable/v1.php index 6d82b5ba08..e748a4a650 100644 --- a/lib/zin/wg/dtable/v1.php +++ b/lib/zin/wg/dtable/v1.php @@ -207,7 +207,7 @@ class dtable extends wg } global $config; - if($config->edition != 'open') + if($config->edition != 'open' && empty($app->installing) && empty($app->upgrading)) { $extendFields = $app->control->loadModel('workflowaction')->getFields($moduleName, $methodName); $extendCols = $app->control->loadModel('flow')->buildDtableCols($extendFields); From 255be05b6bc935b5d2ef709ece66131653580bdd Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 11 Jun 2024 17:55:34 +0800 Subject: [PATCH 2/2] * [perf bug #120189] remove comment tag in sql line. --- module/upgrade/model.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 0f37a57e64..56bc6c2d7b 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -481,13 +481,17 @@ class upgradeModel extends model if($defaultPos === false) return false; // No default in std, don't change. $stdDefault = str_replace("'", '', substr($stdField, $defaultPos + 9)); + $commentPos = stripos($stdDefault, ' COMMENT '); + if($commentPos !== false) $stdDefault = substr($stdDefault, 0, $commentPos); if($stdDefault == 'NULL') return false; // Default is NULL, don't change. if(strpos($stdField, 'text') !== false && empty($stdDefault)) return false; // Default is '' and text type, don't change. $defaultPos = stripos($dbField, ' DEFAULT '); if($defaultPos === false) return true; // No default in db, change it. - $dbDefault = str_replace("'", '', substr($dbField, $defaultPos + 9)); + $dbDefault = str_replace("'", '', substr($dbField, $defaultPos + 9)); + $commentPos = stripos($dbDefault, ' COMMENT '); + if($commentPos !== false) $dbDefault = substr($dbDefault, 0, $commentPos); return $stdDefault != $dbDefault; }