* finish task #2043,2094,2098.
This commit is contained in:
+36
-6
@@ -114,6 +114,14 @@ class dao
|
||||
*/
|
||||
public $method;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -269,7 +277,7 @@ class dao
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->app->triggerError($e->getMessage() . "<p>The sql is: $sql</p>", __FILE__, __LINE__, $exit = true);
|
||||
$this->sqlError($e);
|
||||
}
|
||||
|
||||
$sql = 'SELECT FOUND_ROWS() as recTotal;';
|
||||
@@ -500,7 +508,7 @@ class dao
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->app->triggerError($e->getMessage() . "<p>The sql is: $sql</p>", __FILE__, __LINE__, $exit = true);
|
||||
$this->sqlError($e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,7 +549,7 @@ class dao
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->app->triggerError($e->getMessage() . "<p>The sql is: $sql</p>", __FILE__, __LINE__, $exit = true);
|
||||
$this->sqlError($e);
|
||||
}
|
||||
|
||||
$pager->setRecTotal($row->recTotal);
|
||||
@@ -572,7 +580,7 @@ class dao
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->app->triggerError($e->getMessage() . "<p>The sql is: $sql</p>", __FILE__, __LINE__, $exit = true);
|
||||
$this->sqlError($e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -768,7 +776,7 @@ class dao
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->app->triggerError($e->getMessage() . "<p>The sql is: $sql</p>", __FILE__, __LINE__, $exit = true);
|
||||
$this->sqlError($e);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -981,7 +989,7 @@ class dao
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->app->triggerError($e->getMessage() . "<p>The sql is: $sql</p>", __FILE__, __LINE__, $exit = true);
|
||||
$this->sqlError($e);
|
||||
}
|
||||
|
||||
foreach($rawFields as $rawField)
|
||||
@@ -1028,6 +1036,28 @@ class dao
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process SQL error by code.
|
||||
*
|
||||
* @param object $exception
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
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))
|
||||
{
|
||||
$message .= ' ' . $this->lang->repairTable;
|
||||
}
|
||||
$sql = $this->sqlobj->get();
|
||||
$this->app->triggerError($message . "<p>The sql is: $sql</p>", __FILE__, __LINE__, $exit = true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,6 +61,7 @@ $lang->addFiles = 'Add Files';
|
||||
$lang->files = 'Files ';
|
||||
$lang->pasteText = 'Paste text';
|
||||
$lang->timeout = 'Timed out, please check the network, or retry!';
|
||||
$lang->repairTable = 'The table may be damaged, you can perform bin/checkdb on the command line to try to repair!';
|
||||
$lang->duplicate = '%s has the same title';
|
||||
$lang->unfold = '+';
|
||||
$lang->fold = '-';
|
||||
|
||||
@@ -61,6 +61,7 @@ $lang->addFiles = '上传了附件 ';
|
||||
$lang->files = '附件 ';
|
||||
$lang->pasteText = '粘贴文本 ';
|
||||
$lang->timeout = '连接超时,请检查网络环境,或重试!';
|
||||
$lang->repairTable = '数据库表可能损坏,需要修复,可以在命令行执行bin目录下的checkdb尝试修复!';
|
||||
$lang->duplicate = '已有相同标题的%s';
|
||||
$lang->unfold = '+';
|
||||
$lang->fold = '-';
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
.alert-link:hover {text-decoration: underline;}
|
||||
.alert {width: 100%; display: table;}
|
||||
code{padding-left:0px;}
|
||||
|
||||
@@ -480,9 +480,9 @@ class extensionModel extends model
|
||||
}
|
||||
|
||||
if($return->errors) $return->result = 'fail';
|
||||
$return->mkdirCommands = str_replace('/', DIRECTORY_SEPARATOR, $return->mkdirCommands);
|
||||
$return->mkdirCommands = '<code>' . str_replace('/', DIRECTORY_SEPARATOR, $return->mkdirCommands) . '</code>';
|
||||
$return->errors .= $this->lang->extension->executeCommands . $return->mkdirCommands;
|
||||
if(PHP_OS == 'Linux') $return->errors .= $return->chmodCommands;
|
||||
if(PHP_OS == 'Linux') $return->errors .= '<code>' . $return->chmodCommands . '</code>';
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -707,6 +707,7 @@ class extensionModel extends model
|
||||
$return = new stdclass();
|
||||
$return->result = 'ok';
|
||||
$return->error = '';
|
||||
$ignoreCode = '|1050|1060|1062|1091|1169|';
|
||||
|
||||
$dbFile = $this->getDBFile($extension, $method);
|
||||
if(!file_exists($dbFile)) return $return;
|
||||
@@ -724,9 +725,11 @@ class extensionModel extends model
|
||||
{
|
||||
$this->dbh->query($sql);
|
||||
}
|
||||
catch (PDOException $e)
|
||||
catch(PDOException $e)
|
||||
{
|
||||
$return->error .= '<p>' . $e->getMessage() . "<br />THE SQL IS: $sql</p>";
|
||||
$errorInfo = $e->errorInfo;
|
||||
$errorCode = $errorInfo[1];
|
||||
if(strpos($ignoreCode, "|$errorCode|") === false) $return->error .= '<p>' . $e->getMessage() . "<br />THE SQL IS: $sql</p>";
|
||||
}
|
||||
}
|
||||
if($return->error) $return->result = 'fail';
|
||||
|
||||
@@ -161,7 +161,7 @@ class mail extends control
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
$this->mail->send($this->post->to, $this->lang->mail->subject, $this->lang->mail->content,"", true);
|
||||
$this->mail->send($this->post->to, $this->lang->mail->subject, $this->lang->mail->content, "", true);
|
||||
if($this->mail->isError())
|
||||
{
|
||||
$this->view->error = $this->mail->getError();
|
||||
|
||||
@@ -622,6 +622,7 @@ class upgradeModel extends model
|
||||
public function execSQL($sqlFile)
|
||||
{
|
||||
$mysqlVersion = $this->loadModel('install')->getMysqlVersion();
|
||||
$ignoreCode = '|1050|1060|1062|1091|1169|';
|
||||
|
||||
/* Read the sql file to lines, remove the comment lines, then join theme by ';'. */
|
||||
$sqls = explode("\n", file_get_contents($sqlFile));
|
||||
@@ -652,7 +653,9 @@ class upgradeModel extends model
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
self::$errors[] = $e->getMessage() . "<p>The sql is: $sql</p>";
|
||||
$errorInfo = $e->errorInfo;
|
||||
$errorCode = $errorInfo[1];
|
||||
if(strpos($ignoreCode, "|$errorCode|") === false) self::$errors[] = $e->getMessage() . "<p>The sql is: $sql</p>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user