@@ -1461,14 +1461,13 @@ static int gen_varkey_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
14611461 char * kw , int kw_len , int min_argc , int has_timeout ,
14621462 char * * cmd , int * cmd_len , short * slot )
14631463{
1464- zval * z_args , * z_ele ;
1464+ zval * z_args , * z_ele , ztimeout = { 0 } ;
14651465 HashTable * ht_arr ;
14661466 char * key ;
14671467 int key_free , i , tail ;
14681468 size_t key_len ;
14691469 int single_array = 0 , argc = ZEND_NUM_ARGS ();
14701470 smart_string cmdstr = {0 };
1471- long timeout = 0 ;
14721471 short kslot = -1 ;
14731472 zend_string * zstr ;
14741473
@@ -1489,8 +1488,9 @@ static int gen_varkey_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
14891488 single_array = argc == 1 && Z_TYPE (z_args [0 ]) == IS_ARRAY ;
14901489 } else {
14911490 single_array = argc == 2 && Z_TYPE (z_args [0 ]) == IS_ARRAY &&
1492- Z_TYPE (z_args [1 ]) == IS_LONG ;
1493- timeout = Z_LVAL (z_args [1 ]);
1491+ (Z_TYPE (z_args [1 ]) == IS_LONG || Z_TYPE (z_args [1 ]) == IS_DOUBLE );
1492+ if (single_array )
1493+ ZVAL_COPY_VALUE (& ztimeout , & z_args [1 ]);
14941494 }
14951495
14961496 // If we're running a single array, rework args
@@ -1533,17 +1533,22 @@ static int gen_varkey_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
15331533 zend_string_release (zstr );
15341534 if (key_free ) efree (key );
15351535 } ZEND_HASH_FOREACH_END ();
1536- if (has_timeout ) {
1537- redis_cmd_append_sstr_long (& cmdstr , timeout );
1536+ if (Z_TYPE (ztimeout ) == IS_LONG ) {
1537+ redis_cmd_append_sstr_long (& cmdstr , Z_LVAL (ztimeout ));
1538+ } else if (Z_TYPE (ztimeout ) == IS_DOUBLE ) {
1539+ redis_cmd_append_sstr_dbl (& cmdstr , Z_DVAL (ztimeout ));
15381540 }
15391541 } else {
1540- if (has_timeout && Z_TYPE (z_args [argc - 1 ])!= IS_LONG ) {
1541- php_error_docref (NULL , E_ERROR ,
1542- "Timeout value must be a LONG" );
1543- efree (z_args );
1544- return FAILURE ;
1542+ if (has_timeout ) {
1543+ zend_uchar type = Z_TYPE (z_args [argc - 1 ]);
1544+ if (type == IS_LONG || type == IS_DOUBLE ) {
1545+ ZVAL_COPY_VALUE (& ztimeout , & z_args [argc - 1 ]);
1546+ } else {
1547+ php_error_docref (NULL , E_ERROR , "Timeout value must be a long or double" );
1548+ efree (z_args );
1549+ return FAILURE ;
1550+ }
15451551 }
1546-
15471552 tail = has_timeout ? argc - 1 : argc ;
15481553 for (i = 0 ; i < tail ; i ++ ) {
15491554 zstr = zval_get_string (& z_args [i ]);
@@ -1571,7 +1576,10 @@ static int gen_varkey_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
15711576 zend_string_release (zstr );
15721577 if (key_free ) efree (key );
15731578 }
1574- if (has_timeout ) {
1579+
1580+ if (Z_TYPE (ztimeout ) == IS_DOUBLE ) {
1581+ redis_cmd_append_sstr_dbl (& cmdstr , Z_DVAL (z_args [tail ]));
1582+ } else if (Z_TYPE (ztimeout ) == IS_LONG ) {
15751583 redis_cmd_append_sstr_long (& cmdstr , Z_LVAL (z_args [tail ]));
15761584 }
15771585
0 commit comments