diff --git a/lib/ajax/service.php b/lib/ajax/service.php index 5437f1a4b5d..43ce3f70438 100644 --- a/lib/ajax/service.php +++ b/lib/ajax/service.php @@ -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();