diff --git a/framework/base/helper.class.php b/framework/base/helper.class.php index 24246de3a2..e6049dad90 100644 --- a/framework/base/helper.class.php +++ b/framework/base/helper.class.php @@ -727,6 +727,37 @@ class baseHelper session_id($sessionID); session_start(); } + + /** + * Check DB to repair table. + * + * @param object $exception + * @static + * @access public + * @return string + */ + public static function checkDB2Repair($exception) + { + global $config, $lang; + + $repairCode = '|1034|1035|1194|1195|1459|'; + $errorInfo = $exception->errorInfo; + $errorCode = $errorInfo[1]; + $errorMsg = $errorInfo[2]; + $message = $exception->getMessage(); + + if(strpos($repairCode, "|$errorCode|") !== false or ($errorCode == '1016' and strpos($errorMsg, 'errno: 145') !== false) or strpos($message, 'repair') !== false) + { + if(isset($config->framework->autoRepairTable) and $config->framework->autoRepairTable) + { + header("location: " . $config->webRoot . 'checktable.php'); + exit; + } + return $lang->repairTable; + } + + return null; + } } //------------------------------- 常用函数。Some tool functions.-------------------------------// diff --git a/framework/router.class.php b/framework/router.class.php index 5fdb89956d..690115d388 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -130,20 +130,7 @@ class router extends baseRouter } catch (PDOException $exception) { - $repairCode = '|1034|1035|1194|1195|1459|'; - $errorInfo = $exception->errorInfo; - $errorCode = $errorInfo[1]; - $errorMsg = $errorInfo[2]; - $message = $exception->getMessage(); - - if(strpos($repairCode, "|$errorCode|") !== false or ($errorCode == '1016' and strpos($errorMsg, 'errno: 145') !== false) or strpos($message, 'repair') !== false) - { - if(isset($config->framework->autoRepairTable) and $config->framework->autoRepairTable) - { - header("location: " . $config->webRoot . 'checktable.php'); - exit; - } - } + helper::checkDB2Repair($exception); } } diff --git a/lib/base/dao/dao.class.php b/lib/base/dao/dao.class.php index fae9d3201c..b5ef91d834 100644 --- a/lib/base/dao/dao.class.php +++ b/lib/base/dao/dao.class.php @@ -136,15 +136,6 @@ class baseDAO */ public $autoLang; - /** - * 需要修复表的错误代码 - * The sql code of need repair table. - * - * @var string - * @access public - */ - public $repairCode = '|1034|1035|1194|1195|1459|'; - /** * 执行的请求,所有的查询都保存在该数组。 * The queries executed. Every query will be saved in this array. @@ -1383,16 +1374,9 @@ class baseDAO */ public function sqlError($exception) { - $errorInfo = $exception->errorInfo; - $errorCode = $errorInfo[1]; - $errorMsg = $errorInfo[2]; - $message = $exception->getMessage(); - if(strpos($this->repairCode, "|$errorCode|") !== false or ($errorCode == '1016' and strpos($errorMsg, 'errno: 145') !== false) or strpos($message, 'repair') !== false) - { - global $config; - if(isset($config->framework->autoRepairTable) and $config->framework->autoRepairTable) die(js::locate($config->webRoot . 'checktable.php', 'top')); - $message .= ' ' . $this->lang->repairTable; - } + $message = $exception->getMessage(); + $message .= ' ' . helper::checkDB2Repair($exception); + $sql = $this->sqlobj->get(); $this->app->triggerError($message . "

The sql is: $sql

", __FILE__, __LINE__, $exit = true); } diff --git a/www/checktable.php b/www/checktable.php index 0ee6639cfd..251f9fc69c 100644 --- a/www/checktable.php +++ b/www/checktable.php @@ -61,11 +61,16 @@ if(!file_exists($checkFileName) or (time() - filemtime($checkFileName)) > 60 * 1 $lang = new stdclass(); $lang->misc = new stdclass(); -$lang->storyCommon = ''; -$lang->productCommon = ''; -$lang->projectCommon = ''; -$lang->URCommon = ''; -$lang->SRCommon = ''; +$lang->storyCommon = ''; +$lang->productCommon = ''; +$lang->projectCommon = ''; +$lang->URCommon = ''; +$lang->SRCommon = ''; +$lang->productURCommon = ''; +$lang->productSRCommon = ''; +$lang->planCommon = ''; +$lang->projectSRCommon = ''; +$lang->projectURCommon = ''; include "../module/common/lang/{$clientLang}.php"; include "../module/misc/lang/{$clientLang}.php"; if($status == 'createFile')