]> granicus.if.org Git - php/commitdiff
- MFH: Make clear what's going on and avoid overwriting parameters
authorJohannes Schlüter <johannes@php.net>
Tue, 12 Feb 2008 20:43:50 +0000 (20:43 +0000)
committerJohannes Schlüter <johannes@php.net>
Tue, 12 Feb 2008 20:43:50 +0000 (20:43 +0000)
ext/mysql/php_mysql.c

index c9d0531401b72ecb81dbb498379da9fc7d167311..f6bd8e43439dba41b3237c1991f36dcda06aa4a7 100644 (file)
@@ -556,10 +556,19 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                hashed_details_length = spprintf(&hashed_details, 0, "mysql__%s_", user);
                client_flags = CLIENT_INTERACTIVE;
        } else {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!bl", &host_and_port, &host_len,
-                                                                       &user, &user_len, &passwd, &passwd_len, 
-                                                                       &new_link, &client_flags)==FAILURE) {
-                       return;
+               /* mysql_pconnect does not support new_link parameter */
+               if (persistent) {
+                       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!l", &host_and_port, &host_len,
+                                                                       &user, &user_len, &passwd, &passwd_len,
+                                                                       &client_flags)==FAILURE) {
+                               return;
+               }
+               } else {
+                       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!bl", &host_and_port, &host_len,
+                                                                               &user, &user_len, &passwd, &passwd_len, 
+                                                                               &new_link, &client_flags)==FAILURE) {
+                               return;
+                       }
                }
 
                if (!host_and_port) {
@@ -572,11 +581,6 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                        passwd = MySG(default_password);
                }
 
-               /* mysql_pconnect does not support new_link parameter */
-               if (persistent) {
-                       client_flags= new_link;
-               }
-
                /* disable local infile option for open_basedir */
                if (((PG(open_basedir) && PG(open_basedir)[0] != '\0') || PG(safe_mode)) && (client_flags & CLIENT_LOCAL_FILES)) {
                        client_flags ^= CLIENT_LOCAL_FILES;