mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Use fall back json_last_error_msg
This commit is contained in:
parent
10cfb878be
commit
5002bd4dbe
1 changed files with 1 additions and 10 deletions
|
@ -124,10 +124,6 @@ class JsonView extends View {
|
|||
|
||||
/**
|
||||
* Serialize view vars
|
||||
* For JSON documents, any errors are output using;
|
||||
* PHP 5 >= 5.5.0 : json_last_error_msg()
|
||||
* PHP 5 >= 5.3.0 : json_last_error()
|
||||
* PHP 5 <= 5.2.9 : Generic fall back error
|
||||
*
|
||||
* @param array $serialize The viewVars that need to be serialized
|
||||
* @throws CakeException
|
||||
|
@ -156,12 +152,7 @@ class JsonView extends View {
|
|||
}
|
||||
|
||||
if (function_exists('json_last_error') && json_last_error() !== JSON_ERROR_NONE) {
|
||||
if (function_exists('json_last_error_msg')) {
|
||||
$error = json_last_error_msg();
|
||||
} else {
|
||||
$error = sprintf('JSON encoding failed: Error code %s', json_last_error());
|
||||
}
|
||||
throw new CakeException($error);
|
||||
throw new CakeException(sprintf('JSON_ERROR: %s', json_last_error_msg()));
|
||||
} elseif ($json === false) {
|
||||
throw new CakeException('Failed to parse JSON');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue