MDL-56038 Web services: json_last_error_msg not in PHP 5.4

This commit is contained in:
sam marshall
2016-09-20 14:53:46 +01:00
parent cb3b8c222e
commit 08e3be8806
+6 -1
View File
@@ -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();