mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
캐시가 없는 상황에서 DB 연결 에러시 DB 에러 메세지 대신 php 치명적 에러가 나오는 문제 수정
(라이믹스 오류 화면 출력시에도 DB 연결이 사용되므로 Debug::displayErrorScreen() 함수를 거치면 치명적 에러가 발생되기에 Exception로 처리하지 않았음) 라이믹스가 설치되지 않은 상태에서는 "에러 로그로 확인하라는 메세지" 없이 에러가 바로 출력되도록 수정
This commit is contained in:
parent
843e16f983
commit
c2221a25e6
3 changed files with 31 additions and 18 deletions
|
|
@ -122,7 +122,8 @@ class DB
|
||||||
}
|
}
|
||||||
if(!$db_type && Context::isInstalled())
|
if(!$db_type && Context::isInstalled())
|
||||||
{
|
{
|
||||||
return new BaseObject(-1, 'msg_db_not_setted');
|
Rhymix\Framework\Debug::displayError(lang('msg_db_not_setted'));
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
if(!strncmp($db_type, 'mysql', 5))
|
if(!strncmp($db_type, 'mysql', 5))
|
||||||
{
|
{
|
||||||
|
|
@ -139,7 +140,8 @@ class DB
|
||||||
$class_file = RX_BASEDIR . "classes/db/$class_name.class.php";
|
$class_file = RX_BASEDIR . "classes/db/$class_name.class.php";
|
||||||
if(!file_exists($class_file))
|
if(!file_exists($class_file))
|
||||||
{
|
{
|
||||||
return new BaseObject(-1, 'msg_db_not_setted');
|
Rhymix\Framework\Debug::displayError(sprintf('DB type "%s" is not supported.', $db_type));
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get a singletone instance of the database driver class
|
// get a singletone instance of the database driver class
|
||||||
|
|
|
||||||
|
|
@ -73,16 +73,16 @@ class DBMySQL extends DB
|
||||||
// Check connection error
|
// Check connection error
|
||||||
if($mysqli->connect_errno)
|
if($mysqli->connect_errno)
|
||||||
{
|
{
|
||||||
$this->setError($mysqli->connect_errno, $mysqli->connect_error);
|
Rhymix\Framework\Debug::displayError(sprintf('DB ERROR %d : %s', $mysqli->connect_errno, $mysqli->connect_error));
|
||||||
return;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check DB version
|
// Check DB version
|
||||||
$this->db_version = $mysqli->server_info;
|
$this->db_version = $mysqli->server_info;
|
||||||
if (version_compare($this->db_version, '5.0.7', '<'))
|
if (version_compare($this->db_version, '5.0.7', '<'))
|
||||||
{
|
{
|
||||||
$this->setError(-1, 'Rhymix requires MySQL 5.0.7 or later. Current MySQL version is ' . $this->db_version);
|
Rhymix\Framework\Debug::displayError('Rhymix requires MySQL 5.0.7 or later. Current MySQL version is ' . $this->db_version);
|
||||||
return;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set DB charset
|
// Set DB charset
|
||||||
|
|
|
||||||
|
|
@ -650,7 +650,7 @@ class Debug
|
||||||
}
|
}
|
||||||
|
|
||||||
// Localize the error message.
|
// Localize the error message.
|
||||||
$display_error_message = ini_get('display_errors') || Session::isAdmin();
|
$display_error_message = ini_get('display_errors') || !\Context::isInstalled() || Session::isAdmin();
|
||||||
$message = $display_error_message ? $message : lang('msg_server_error_see_log');
|
$message = $display_error_message ? $message : lang('msg_server_error_see_log');
|
||||||
if ($message === 'msg_server_error_see_log')
|
if ($message === 'msg_server_error_see_log')
|
||||||
{
|
{
|
||||||
|
|
@ -664,17 +664,28 @@ class Debug
|
||||||
}
|
}
|
||||||
catch (\Error $e)
|
catch (\Error $e)
|
||||||
{
|
{
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
self::displayError($message);
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'GET' || !isset($_SERVER['HTTP_X_REQUESTED_WITH']))
|
}
|
||||||
{
|
}
|
||||||
header('Content-Type: text/html; charset=UTF-8');
|
|
||||||
echo sprintf('<html><head><meta charset="UTF-8" /><title>%s</title></head><body>%s</body></html>', escape($title, false), escape($message, false));
|
/**
|
||||||
}
|
* Display a default error.
|
||||||
else
|
*
|
||||||
{
|
* @param string $message
|
||||||
header('Content-Type: application/json; charset=UTF-8');
|
* @return void
|
||||||
echo json_encode(array('error' => -1, 'message' => escape($message, false)), \JSON_UNESCAPED_UNICODE);
|
*/
|
||||||
}
|
public static function displayError($message)
|
||||||
|
{
|
||||||
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'GET' || !isset($_SERVER['HTTP_X_REQUESTED_WITH']))
|
||||||
|
{
|
||||||
|
header('Content-Type: text/html; charset=UTF-8');
|
||||||
|
echo sprintf('<html><head><meta charset="UTF-8" /><title>Server Error</title></head><body>%s</body></html>', escape($message, false));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
header('Content-Type: application/json; charset=UTF-8');
|
||||||
|
echo json_encode(array('error' => -1, 'message' => escape($message, false)), \JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue