Skip to content

Commit b8de91c

Browse files
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
1 parent 92dd256 commit b8de91c

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

library.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,14 +2686,22 @@ redis_vlinks_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
26862686
PHP_REDIS_API int
26872687
redis_deserialize_vgetattr_reply(zval *zret, const char *str, size_t len) {
26882688
#ifdef HAVE_REDIS_JSON
2689-
if (php_json_decode(zret, str, len, 1, PHP_JSON_PARSER_DEFAULT_DEPTH)
2690-
== FAILURE)
2689+
#if PHP_VERSION_ID < 80000
2690+
#define PHP_JSON_IN(s) ((char*)s)
2691+
#else
2692+
#define PHP_JSON_IN(s) (s)
2693+
#endif
2694+
2695+
if (php_json_decode(zret, PHP_JSON_IN(str), len, 1,
2696+
PHP_JSON_PARSER_DEFAULT_DEPTH) == FAILURE)
26912697
{
26922698
php_error_docref(NULL, E_WARNING, "Failed to deserialize attributes");
26932699
return FAILURE;
26942700
}
26952701

26962702
return SUCCESS;
2703+
2704+
#undef PHP_JSON_IN
26972705
#else
26982706
php_error_docref(NULL, E_WARNING,
26992707
"PhpRedis is not compiled with JSON support");

redis_commands.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7043,8 +7043,8 @@ int
70437043
redis_vlinks_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
70447044
char **cmd, int *cmd_len, short *slot, void **ctx)
70457045
{
7046-
zend_bool withscores = false;
70477046
smart_string cmdstr = {0};
7047+
zend_bool withscores = 0;
70487048
zend_string *key;
70497049
zval *member;
70507050

0 commit comments

Comments
 (0)