MDL-56038 Web services: json_last_error_msg not in PHP 5.4
This commit is contained in:
@@ -36,7 +36,12 @@ $rawjson = file_get_contents('php://input');
|
||||
|
||||
$requests = json_decode($rawjson, true);
|
||||
if ($requests === null) {
|
||||
$lasterror = json_last_error_msg();
|
||||
if (function_exists('json_last_error_msg')) {
|
||||
$lasterror = json_last_error_msg();
|
||||
} else {
|
||||
// Fall back to numeric error for older PHP version.
|
||||
$lasterror = json_last_error();
|
||||
}
|
||||
throw new coding_exception('Invalid json in request: ' . $lasterror);
|
||||
}
|
||||
$responses = array();
|
||||
|
||||
Reference in New Issue
Block a user