From b8de91c9e09dfaf6850273619b5ed92ce5d88db9 Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Fri, 29 Aug 2025 11:37:51 -0700 Subject: [PATCH] Fix errors and a warning * PHP < 8.0 took a `char*` as `php_json_decode` input, whereas newer versions take a const char * so ifdef around this. * Fix compilation errors due to `false` not being defined. So as to make a minimal change we can just use 0 and 1 --- library.c | 12 ++++++++++-- redis_commands.c | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/library.c b/library.c index e9801ee..d747d84 100644 --- a/library.c +++ b/library.c @@ -2686,14 +2686,22 @@ fail: PHP_REDIS_API int redis_deserialize_vgetattr_reply(zval *zret, const char *str, size_t len) { #ifdef HAVE_REDIS_JSON - if (php_json_decode(zret, str, len, 1, PHP_JSON_PARSER_DEFAULT_DEPTH) - == FAILURE) + #if PHP_VERSION_ID < 80000 + #define PHP_JSON_IN(s) ((char*)s) + #else + #define PHP_JSON_IN(s) (s) + #endif + + if (php_json_decode(zret, PHP_JSON_IN(str), len, 1, + PHP_JSON_PARSER_DEFAULT_DEPTH) == FAILURE) { php_error_docref(NULL, E_WARNING, "Failed to deserialize attributes"); return FAILURE; } return SUCCESS; + + #undef PHP_JSON_IN #else php_error_docref(NULL, E_WARNING, "PhpRedis is not compiled with JSON support"); diff --git a/redis_commands.c b/redis_commands.c index 329bd0c..d51371b 100644 --- a/redis_commands.c +++ b/redis_commands.c @@ -7043,8 +7043,8 @@ int redis_vlinks_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, char **cmd, int *cmd_len, short *slot, void **ctx) { - zend_bool withscores = false; smart_string cmdstr = {0}; + zend_bool withscores = 0; zend_string *key; zval *member;