diff options
author | michael-grunder <michael.grunder@gmail.com> | 2019-05-12 22:19:21 +0300 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2019-05-12 22:19:21 +0300 |
commit | 96c571391e69b0a4f9c40bed393e4e8161ead71a (patch) | |
tree | 9d884c8bcae74f2c492597503a7f83b84f951a13 /library.c | |
parent | 98bd2886c391d01607e1c4d1d06faeebbd4ed2c3 (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.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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() } |