Skip to content

Commit

Permalink
Respond with a properly encoded JSON message on fatal error
Browse files Browse the repository at this point in the history
  • Loading branch information
roccivic committed Oct 30, 2012
1 parent 2737754 commit acdd33c
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions libraries/core.lib.php
Expand Up @@ -212,29 +212,35 @@ function PMA_fatalError(
} elseif (is_array($message_args)) {
$error_message = vsprintf($error_message, $message_args);
}
$error_message = strtr($error_message, array('<br />' => '[br]'));

if (function_exists('__')) {
$error_header = __('Error');
if ($GLOBALS['is_ajax_request']) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', PMA_Message::error($error_message)->getDisplay());
} else {
$error_header = 'Error';
}
$error_message = strtr($error_message, array('<br />' => '[br]'));

// Displays the error message
$lang = $GLOBALS['available_languages'][$GLOBALS['lang']][1];
$dir = $GLOBALS['text_dir'];
if (function_exists('__')) {
$error_header = __('Error');
} else {
$error_header = 'Error';
}

// on fatal errors it cannot hurt to always delete the current session
if ($delete_session
&& isset($GLOBALS['session_name'])
&& isset($_COOKIE[$GLOBALS['session_name']])
) {
$GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']);
}
$lang = $GLOBALS['available_languages'][$GLOBALS['lang']][1];
$dir = $GLOBALS['text_dir'];

include './libraries/error.inc.php';
// on fatal errors it cannot hurt to always delete the current session
if ($delete_session
&& isset($GLOBALS['session_name'])
&& isset($_COOKIE[$GLOBALS['session_name']])
) {
$GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']);
}

if (!defined('TESTSUITE')) {
// Displays the error message
include './libraries/error.inc.php';
}
if (! defined('TESTSUITE')) {
exit;
}
}
Expand Down

0 comments on commit acdd33c

Please sign in to comment.