Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2019-05-12 22:19:21 +0300
committermichael-grunder <michael.grunder@gmail.com>2019-05-12 22:19:21 +0300
commit96c571391e69b0a4f9c40bed393e4e8161ead71a (patch)
tree9d884c8bcae74f2c492597503a7f83b84f951a13 /library.c
parent98bd2886c391d01607e1c4d1d06faeebbd4ed2c3 (diff)
Make JSON deserialization work in php 7.0.x
In PHP 7.0.x the json_decode function returned void so we need to test the error_code global to determine if deserialization failed.
Diffstat (limited to 'library.c')
-rw-r--r--library.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/library.c b/library.c
index 87aa5697..df675dc9 100644
--- a/library.c
+++ b/library.c
@@ -2291,7 +2291,13 @@ redis_unserialize(RedisSock* redis_sock, const char *val, int val_len,
#endif
break;
case REDIS_SERIALIZER_JSON:
+#if PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 1
+ JSON_G(error_code) = PHP_JSON_ERROR_NONE;
+ php_json_decode(z_ret, (char*)val, val_len, 1, PHP_JSON_PARSER_DEFAULT_DEPTH);
+ ret = JSON_G(error_code) == PHP_JSON_ERROR_NONE;
+#else
ret = !php_json_decode(z_ret, (char *)val, val_len, 1, PHP_JSON_PARSER_DEFAULT_DEPTH);
+#endif
break;
EMPTY_SWITCH_DEFAULT_CASE()
}