8000 Added a specific clause in the failure/failover logic for the TYPE co… · devsnippet/phpredis@2b101e2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b101e2

Browse files
Added a specific clause in the failure/failover logic for the TYPE command,
as it will return a LONG response of ZERO if the key is not found. Given that other commands can actually return zero and are not failures, the specific check was needed. Fixes issue phpredis#207
1 parent 8af15d7 commit 2b101e2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

redis_array.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,11 @@ ra_forward_call(INTERNAL_FUNCTION_PARAMETERS, RedisArray *ra, const char *cmd, i
339339
call_user_function(&redis_ce->function_table, &redis_inst, &z_fun, return_value, argc, z_callargs TSRMLS_CC);
340340

341341
failed = 0;
342-
if((Z_TYPE_P(return_value) == IS_BOOL && Z_BVAL_P(return_value) == 0) || (Z_TYPE_P(return_value) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(return_value)) == 0)) {
342+
if((Z_TYPE_P(return_value) == IS_BOOL && Z_BVAL_P(return_value) == 0) ||
343+
(Z_TYPE_P(return_value) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(return_value)) == 0) ||
344+
(Z_TYPE_P(return_value) == IS_LONG && Z_LVAL_P(return_value) == 0 && !strcasecmp(cmd, "TYPE")))
345+
346+
{
343347
failed = 1;
344348
}
345349

0 commit comments

Comments
 (0)
0