Gracefully handle early fatal errors in AJAX requests

Generate response manually when Response object is not yet ready to be
used but we need AJAX response.

Fixes #13092

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2017-06-08 15:43:13 +02:00
parent e317e481ac
commit f4ae5f0d25
2 changed files with 11 additions and 9 deletions

View File

@ -11,6 +11,7 @@ phpMyAdmin - ChangeLog
- issue #13362 Fixed loading additional javascripts
- issue #13343 Fixed editing QBE
- issue #13193 Improved documentation on user settings
- issue #13092 Gracefully handle early fatal errors in AJAX requests
4.7.1 (2017-05-25)
- issue #13132 Always execute tracking queries as controluser

View File

@ -222,17 +222,18 @@ function PMA_fatalError($error_message, $message_args = null) {
}
/*
* Avoid using Response if Config is not yet loaded
* Avoid using Response class as config does not have to be loaded yet
* (this can happen on early fatal error)
*/
if (isset($GLOBALS['Config'])) {
$response = Response::getInstance();
} else {
$response = null;
}
if (! is_null($response) && $response->isAjax()) {
$response->setRequestStatus(false);
$response->addJSON('message', PMA\libraries\Message::error($error_message));
if (! empty($_REQUEST['ajax_request'])) {
// Generate JSON manually
PMA_headerJSON();
echo json_encode(
array(
'success' => false,
'error' => Message::error($error_message)->getDisplay(),
)
);
} else {
$error_message = strtr($error_message, array('<br />' => '[br]'));