Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96c5713

Browse files
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.
1 parent 98bd288 commit 96c5713

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

library.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,13 @@ redis_unserialize(RedisSock* redis_sock, const char *val, int val_len,
22912291
#endif
22922292
break;
22932293
case REDIS_SERIALIZER_JSON:
2294+
#if PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 1
2295+
JSON_G(error_code) = PHP_JSON_ERROR_NONE;
2296+
php_json_decode(z_ret, (char*)val, val_len, 1, PHP_JSON_PARSER_DEFAULT_DEPTH);
2297+
ret = JSON_G(error_code) == PHP_JSON_ERROR_NONE;
2298+
#else
22942299
ret = !php_json_decode(z_ret, (char *)val, val_len, 1, PHP_JSON_PARSER_DEFAULT_DEPTH);
2300+
#endif
22952301
break;
22962302
EMPTY_SWITCH_DEFAULT_CASE()
22972303
}

0 commit comments

Comments
 (0)