From 07a84ab6a81c68942c78829aa11307ed6dea5903 Mon Sep 17 00:00:00 2001 From: Tom Lorentsen Date: Sat, 26 Aug 2017 01:01:58 +0100 Subject: [PATCH] Return null on empty json string PHP7 uses the JSOND extension for parsing JSON which now throws an error on an empty string. The JSON response is checked whether it is empty before decoding it and returns null for backwards compatibility. --- lib/OpenCloud/Common/Http/Message/Formatter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/OpenCloud/Common/Http/Message/Formatter.php b/lib/OpenCloud/Common/Http/Message/Formatter.php index 1f2b8c2a4..4b7e01b71 100644 --- a/lib/OpenCloud/Common/Http/Message/Formatter.php +++ b/lib/OpenCloud/Common/Http/Message/Formatter.php @@ -28,6 +28,9 @@ public static function decode(Response $response) { if (strpos($response->getHeader(Header::CONTENT_TYPE), Mime::JSON) !== false) { $string = (string) $response->getBody(); + if ('' === $string) { + return null; + } $response = json_decode($string); self::checkJsonError($string);