From ddfa3d8d664d087f51e17e684c7cff13374cebdf Mon Sep 17 00:00:00 2001 From: wyd621 Date: Mon, 12 Aug 2013 08:56:09 +0800 Subject: [PATCH] * fix a bug for upgrade. * change zt_custom to zt_lang. --- config/config.php | 2 +- db/update4.3.sql | 2 +- db/zentao.sql | 4 ++-- module/common/model.php | 1 + module/custom/model.php | 6 +++--- www/upgrade.php | 1 + 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/config/config.php b/config/config.php index 63357b012e..6a8eef8926 100644 --- a/config/config.php +++ b/config/config.php @@ -134,7 +134,7 @@ define('TABLE_FILE', '`' . $config->db->prefix . 'file`'); define('TABLE_HISTORY', '`' . $config->db->prefix . 'history`'); define('TABLE_EXTENSION', '`' . $config->db->prefix . 'extension`'); define('TABLE_WEBAPP', '`' . $config->db->prefix . 'webapp`'); -define('TABLE_CUSTOM', '`' . $config->db->prefix . 'custom`'); +define('TABLE_LANG', '`' . $config->db->prefix . 'lang`'); $config->objectTables['product'] = TABLE_PRODUCT; $config->objectTables['story'] = TABLE_STORY; diff --git a/db/update4.3.sql b/db/update4.3.sql index 5ac5c8d34b..ab58d360af 100644 --- a/db/update4.3.sql +++ b/db/update4.3.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS `zt_custom` ( +CREATE TABLE IF NOT EXISTS `zt_lang` ( `id` mediumint(8) unsigned NOT NULL auto_increment, `lang` varchar(30) NOT NULL, `module` varchar(30) NOT NULL, diff --git a/db/zentao.sql b/db/zentao.sql index d94a2af0f8..0e45ee81ed 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -155,8 +155,8 @@ CREATE TABLE IF NOT EXISTS `zt_config` ( PRIMARY KEY (`id`), UNIQUE KEY `unique` (`owner`,`module`,`section`,`key`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- DROP TABLE IF EXISTS `zt_custom`; -CREATE TABLE IF NOT EXISTS `zt_custom` ( +-- DROP TABLE IF EXISTS `zt_lang`; +CREATE TABLE IF NOT EXISTS `zt_lang` ( `id` mediumint(8) unsigned NOT NULL auto_increment, `lang` varchar(30) NOT NULL, `module` varchar(30) NOT NULL, diff --git a/module/common/model.php b/module/common/model.php index 5ae314082d..14524ceff9 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -126,6 +126,7 @@ class commonModel extends model */ public function loadCustomFromDB() { + if(defined('IN_UPGRADE')) return; if(!$this->config->db->name) return; $records = $this->loadModel('custom')->getAll(); if(!$records) return; diff --git a/module/custom/model.php b/module/custom/model.php index 71914c1025..719b3c1580 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -19,7 +19,7 @@ class customModel extends model */ public function getAll() { - $allCustomLang = $this->dao->select('*')->from(TABLE_CUSTOM)->orderBy('lang,id')->fetchAll('id'); + $allCustomLang = $this->dao->select('*')->from(TABLE_LANG)->orderBy('lang,id')->fetchAll('id'); $currentLang = $this->app->getClientLang(); $processedLang = array(); @@ -59,7 +59,7 @@ class customModel extends model $item->value = $value; $item->system = $system; - $this->dao->replace(TABLE_CUSTOM)->data($item)->exec(); + $this->dao->replace(TABLE_LANG)->data($item)->exec(); } /** @@ -116,7 +116,7 @@ class customModel extends model */ public function createDAO($params, $method = 'select') { - return $this->dao->$method('*')->from(TABLE_CUSTOM)->where('1 = 1') + return $this->dao->$method('*')->from(TABLE_LANG)->where('1 = 1') ->beginIF($params['lang'])->andWhere('lang')->in($params['lang'])->fi() ->beginIF($params['module'])->andWhere('module')->in($params['module'])->fi() ->beginIF($params['section'])->andWhere('section')->in($params['section'])->fi() diff --git a/www/upgrade.php b/www/upgrade.php index e2bad61d14..0ce2755eaf 100644 --- a/www/upgrade.php +++ b/www/upgrade.php @@ -10,6 +10,7 @@ * @link http://www.zentao.net */ /* Judge my.php exists or not. */ +define('IN_UPGRADE', true); $myConfig = dirname(dirname(__FILE__)) . '/config/my.php'; if(!file_exists($myConfig)) {