Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6022376

Browse files
Allow persistent_id to be passed as NULL with strict_types enabled.
Right now it is not possible to pass NULL as the persistent_id if strict types are enabled. This change allows the argument to be NULL. Addresses issue #1551
1 parent 4f35205 commit 6022376

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

redis.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ PHP_REDIS_API int
906906
redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
907907
{
908908
zval *object;
909-
char *host = NULL, *persistent_id = "";
909+
char *host = NULL, *persistent_id = NULL;
910910
zend_long port = -1, retry_interval = 0;
911911
size_t host_len, persistent_id_len;
912912
double timeout = 0.0, read_timeout = 0.0;
@@ -919,13 +919,16 @@ redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
919919
#endif
920920

921921
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
922-
"Os|ldsld", &object, redis_ce, &host,
922+
"Os|lds!ld", &object, redis_ce, &host,
923923
&host_len, &port, &timeout, &persistent_id,
924924
&persistent_id_len, &retry_interval,
925925
&read_timeout) == FAILURE)
926926
{
927927
return FAILURE;
928-
} else if (!persistent) {
928+
}
929+
930+
/* Disregard persistent_id if we're not opening a persistent connection */
931+
if (!persistent) {
929932
persistent_id = NULL;
930933
}
931934

0 commit comments

Comments
 (0)