@@ -4394,9 +4394,15 @@ PHPAPI void generic_z_command(INTERNAL_FUNCTION_PARAMETERS, char *command, int c
4394
4394
zend_hash_get_current_data_ex (arr_weights_hash , (void * * ) & data , & pointer ) == SUCCESS ;
4395
4395
zend_hash_move_forward_ex (arr_weights_hash , & pointer )) {
4396
4396
4397
- if (Z_TYPE_PP (data ) != IS_LONG && Z_TYPE_PP (data ) != IS_DOUBLE ) {
4398
- continue ; // ignore non-numeric arguments.
4399
- }
4397
+ // Ignore non numeric arguments, unless they're the special Redis numbers
4398
+ // "inf" ,"-inf", and "+inf" which can be passed as weights
4399
+ if (Z_TYPE_PP (data ) != IS_LONG && Z_TYPE_PP (data ) != IS_DOUBLE &&
4400
+ strncasecmp (Z_STRVAL_PP (data ), "inf" , sizeof ("inf" )) != 0 &&
4401
+ strncasecmp (Z_STRVAL_PP (data ), "-inf" , sizeof ("-inf" )) != 0 &&
4402
+ strncasecmp (Z_STRVAL_PP (data ), "+inf" , sizeof ("+inf" )) != 0 )
4403
+ {
4404
+ continue ;
4405
+ }
4400
4406
4401
4407
old_cmd = NULL ;
4402
4408
if (* cmd ) {
@@ -4412,12 +4418,18 @@ PHPAPI void generic_z_command(INTERNAL_FUNCTION_PARAMETERS, char *command, int c
4412
4418
, integer_length (Z_LVAL_PP (data )), Z_LVAL_PP (data ));
4413
4419
4414
4420
} else if (Z_TYPE_PP (data ) == IS_DOUBLE ) {
4415
-
4416
4421
cmd_len = redis_cmd_format (& cmd ,
4417
4422
"%s" /* cmd */
4418
4423
"$%f" _NL /* data, including size */
4419
4424
, cmd , cmd_len
4420
4425
, Z_DVAL_PP (data ));
4426
+ } else if (Z_TYPE_PP (data ) == IS_STRING ) {
4427
+ cmd_len = redis_cmd_format (& cmd ,
4428
+ "%s" /* cmd */
4429
+ "$%d" _NL /* data len */
4430
+ "%s" _NL /* data */
4431
+ , cmd , cmd_len , Z_STRLEN_PP (data ),
4432
+ Z_STRVAL_PP (data ), Z_STRLEN_PP (data ));
4421
4433
}
4422
4434
4423
4435
// keep track of elements added
0 commit comments