@@ -2578,39 +2578,38 @@ PHP_METHOD(RedisCluster, lastsave) {
25782578 * proto array RedisCluster::info(array host_port, [string $arg]) */
25792579PHP_METHOD (RedisCluster , info ) {
25802580 redisCluster * c = GET_CONTEXT ();
2581+ zval * node = NULL , * args = NULL ;
2582+ smart_string cmdstr = {0 };
25812583 REDIS_REPLY_TYPE rtype ;
2582- char * cmd , * opt = NULL ;
2583- int cmd_len ;
2584- size_t opt_len = 0 ;
2584+ zend_string * section ;
25852585 void * ctx = NULL ;
2586-
2587- zval * z_arg ;
2586+ int i , argc ;
25882587 short slot ;
25892588
2590- if (zend_parse_parameters (ZEND_NUM_ARGS (), "z|s" , & z_arg , & opt ,
2591- & opt_len ) == FAILURE )
2592- {
2589+ ZEND_PARSE_PARAMETERS_START (1 , -1 )
2590+ Z_PARAM_ZVAL (node )
2591+ Z_PARAM_OPTIONAL
2592+ Z_PARAM_VARIADIC ('*' , args , argc )
2593+ ZEND_PARSE_PARAMETERS_END ();
2594+
2595+ if ((slot = cluster_cmd_get_slot (c , node )) < 0 )
25932596 RETURN_FALSE ;
2594- }
25952597
2596- /* Treat INFO as non read-only, as we probably want the master */
2597- c -> readonly = 0 ;
2598+ REDIS_CMD_INIT_SSTR_STATIC (& cmdstr , argc , "INFO" );
25982599
2599- slot = cluster_cmd_get_slot (c , z_arg );
2600- if (slot < 0 ) {
2601- RETURN_FALSE ;
2602- }
2600+ /* Direct this command at the master */
2601+ c -> readonly = 0 ;
26032602
2604- if ( opt != NULL ) {
2605- cmd_len = redis_spprintf ( NULL , NULL , & cmd , "INFO" , "s" , opt , opt_len );
2606- } else {
2607- cmd_len = redis_spprintf ( NULL , NULL , & cmd , "INFO" , "" );
2603+ for ( i = 0 ; i < argc ; i ++ ) {
2604+ section = zval_get_string ( & args [ i ] );
2605+ redis_cmd_append_sstr_zstr ( & cmdstr , section );
2606+ zend_string_release ( section );
26082607 }
26092608
26102609 rtype = CLUSTER_IS_ATOMIC (c ) ? TYPE_BULK : TYPE_LINE ;
2611- if (cluster_send_slot (c , slot , cmd , cmd_len , rtype ) < 0 ) {
2610+ if (cluster_send_slot (c , slot , cmdstr . c , cmdstr . len , rtype ) < 0 ) {
26122611 CLUSTER_THROW_EXCEPTION ("Unable to send INFO command to specific node" , 0 );
2613- efree (cmd );
2612+ efree (cmdstr . c );
26142613 RETURN_FALSE ;
26152614 }
26162615
@@ -2620,7 +2619,7 @@ PHP_METHOD(RedisCluster, info) {
26202619 CLUSTER_ENQUEUE_RESPONSE (c , slot , cluster_info_resp , ctx );
26212620 }
26222621
2623- efree (cmd );
2622+ efree (cmdstr . c );
26242623}
26252624/* }}} */
26262625
0 commit comments