MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:ahristov Date:February 22 2008 11:49am
Subject:PHP mysqlnd svn commit: r1303 - in trunk: php5/ext/mysqli php6/ext/mysqli
View as plain text  
Author: ahristov
Date: 2008-02-22 12:49:32 +0100 (Fri, 22 Feb 2008)
New Revision: 1303

Modified:
   trunk/php5/ext/mysqli/mysqli.c
   trunk/php5/ext/mysqli/mysqli_api.c
   trunk/php5/ext/mysqli/mysqli_fe.c
   trunk/php5/ext/mysqli/mysqli_nonapi.c
   trunk/php5/ext/mysqli/php_mysqli_structs.h
   trunk/php6/ext/mysqli/mysqli.c
   trunk/php6/ext/mysqli/mysqli_api.c
   trunk/php6/ext/mysqli/mysqli_fe.c
   trunk/php6/ext/mysqli/mysqli_nonapi.c
   trunk/php6/ext/mysqli/php_mysqli_structs.h
Log:
Fix API bug. 
$c = new mysqli() constructs
$c->connect() connects, with defaults. Till now it used to return NULL and
not connect.



Modified: trunk/php5/ext/mysqli/mysqli.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli.c	2008-02-21 15:24:49 UTC (rev 1302)
+++ trunk/php5/ext/mysqli/mysqli.c	2008-02-22 11:49:32 UTC (rev 1303)
@@ -54,9 +54,6 @@
 MYSQLND_QCACHE		*mysqli_mysqlnd_qcache;
 #endif
 
-
-extern void php_mysqli_connect(INTERNAL_FUNCTION_PARAMETERS);
-
 typedef int (*mysqli_read_t)(mysqli_object *obj, zval **retval TSRMLS_DC);
 typedef int (*mysqli_write_t)(mysqli_object *obj, zval *newval TSRMLS_DC);
 
@@ -432,7 +429,7 @@
 
 		f.type = ZEND_INTERNAL_FUNCTION;
 		if (obj->zo.ce == mysqli_link_class_entry) {
-			f.handler = ZEND_FN(mysqli_connect);
+			f.handler = ZEND_FN(mysqli_link_construct);
 		} else if (obj->zo.ce == mysqli_stmt_class_entry) {
 			f.handler = ZEND_FN(mysqli_stmt_construct);
 		} else if (obj->zo.ce == mysqli_result_class_entry) {

Modified: trunk/php5/ext/mysqli/mysqli_api.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli_api.c	2008-02-21 15:24:49 UTC (rev 1302)
+++ trunk/php5/ext/mysqli/mysqli_api.c	2008-02-22 11:49:32 UTC (rev 1303)
@@ -1595,7 +1595,7 @@
    Open a connection to a mysql server */ 
 PHP_FUNCTION(mysqli_real_connect)
 {
-	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE);
+	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE, FALSE);
 }
 /* }}} */
 

Modified: trunk/php5/ext/mysqli/mysqli_fe.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli_fe.c	2008-02-21 15:24:49 UTC (rev 1302)
+++ trunk/php5/ext/mysqli/mysqli_fe.c	2008-02-22 11:49:32 UTC (rev 1303)
@@ -215,7 +215,7 @@
 	PHP_FALIAS(set_local_infile_handler,mysqli_set_local_infile_handler,NULL)
 #endif
 	PHP_FALIAS(multi_query,mysqli_multi_query,NULL)
-	PHP_FALIAS(mysqli,mysqli_connect,NULL)
+	PHP_FALIAS(mysqli,mysqli_link_construct,NULL)
 	PHP_FALIAS(more_results,mysqli_more_results, NULL)
 	PHP_FALIAS(next_result, mysqli_next_result, NULL)
 	PHP_FALIAS(options,mysqli_options,NULL)

Modified: trunk/php5/ext/mysqli/mysqli_nonapi.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli_nonapi.c	2008-02-21 15:24:49 UTC (rev 1302)
+++ trunk/php5/ext/mysqli/mysqli_nonapi.c	2008-02-22 11:49:32 UTC (rev 1303)
@@ -33,7 +33,7 @@
 
 #define SAFE_STR(a) ((a)?a:"")
 
-void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect)
+void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect,
zend_bool in_ctor)
 {
 	MY_MYSQL			*mysql = NULL;
 	MYSQLI_RESOURCE		*mysqli_resource = NULL;
@@ -48,7 +48,7 @@
 	zend_rsrc_list_entry	*le;
 	mysqli_plist_entry *plist = NULL;
 
-	if (getThis() && !ZEND_NUM_ARGS()) {
+	if (getThis() && !ZEND_NUM_ARGS() && in_ctor) {
 		RETURN_NULL();
 	}
 	hostname = username = dbname = passwd = socket = NULL;
@@ -76,7 +76,6 @@
 			mysql = (MY_MYSQL *) ecalloc(1, sizeof(MY_MYSQL));
 		}
 		flags |= CLIENT_MULTI_RESULTS; /* needed for mysql_multi_query() */
-
 	} else {
 		/* We have flags too */
 		if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|sssslsl",
&object, mysqli_link_class_entry,
@@ -84,6 +83,7 @@
 										&flags) == FAILURE) {
 			return;
 		}
+
 		mysqli_resource = ((mysqli_object *) zend_object_store_get_object(object
TSRMLS_CC))->ptr;
 		MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &object, "mysqli_link",
MYSQLI_STATUS_INITIALIZED);
 
@@ -285,11 +285,20 @@
    Open a connection to a mysql server */ 
 PHP_FUNCTION(mysqli_connect)
 {
-	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE);
+	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE, FALSE);
 }
 /* }}} */
 
 
+/* {{{ proto object mysqli_link_construct()
+  */ 
+PHP_FUNCTION(mysqli_link_construct)
+{
+	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE, TRUE);
+}
+/* }}} */
+
+
 /* {{{ proto int mysqli_connect_errno(void)
    Returns the numerical value of the error message from last connect command */
 PHP_FUNCTION(mysqli_connect_errno)

Modified: trunk/php5/ext/mysqli/php_mysqli_structs.h
===================================================================
--- trunk/php5/ext/mysqli/php_mysqli_structs.h	2008-02-21 15:24:49 UTC (rev 1302)
+++ trunk/php5/ext/mysqli/php_mysqli_structs.h	2008-02-22 11:49:32 UTC (rev 1303)
@@ -353,7 +353,7 @@
 PHP_MYSQLI_API void mysqli_register_result(zval *return_value, void *result TSRMLS_DC);
 PHP_MYSQLI_API void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC);
 
-void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect);
+void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect,
zend_bool in_ctor);
 
 
 ZEND_BEGIN_MODULE_GLOBALS(mysqli)
@@ -450,6 +450,7 @@
 PHP_FUNCTION(mysqli_insert_id);
 PHP_FUNCTION(mysqli_init);
 PHP_FUNCTION(mysqli_kill);
+PHP_FUNCTION(mysqli_link_construct);
 PHP_FUNCTION(mysqli_set_local_infile_default);
 PHP_FUNCTION(mysqli_set_local_infile_handler);
 PHP_FUNCTION(mysqli_more_results);

Modified: trunk/php6/ext/mysqli/mysqli.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli.c	2008-02-21 15:24:49 UTC (rev 1302)
+++ trunk/php6/ext/mysqli/mysqli.c	2008-02-22 11:49:32 UTC (rev 1303)
@@ -57,8 +57,6 @@
 #endif
 
 
-extern void php_mysqli_connect(INTERNAL_FUNCTION_PARAMETERS);
-
 typedef int (*mysqli_read_t)(mysqli_object *obj, zval **retval TSRMLS_DC);
 typedef int (*mysqli_write_t)(mysqli_object *obj, zval *newval TSRMLS_DC);
 
@@ -426,7 +424,7 @@
 
 		f.type = ZEND_INTERNAL_FUNCTION;
 		if (obj->zo.ce == mysqli_link_class_entry) {
-			f.handler = ZEND_FN(mysqli_connect);
+			f.handler = ZEND_FN(mysqli_link_construct);
 		} else if (obj->zo.ce == mysqli_stmt_class_entry) {
 			f.handler = ZEND_FN(mysqli_stmt_construct);
 		} else if (obj->zo.ce == mysqli_result_class_entry) {

Modified: trunk/php6/ext/mysqli/mysqli_api.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli_api.c	2008-02-21 15:24:49 UTC (rev 1302)
+++ trunk/php6/ext/mysqli/mysqli_api.c	2008-02-22 11:49:32 UTC (rev 1303)
@@ -1669,7 +1669,7 @@
    Open a connection to a mysql server */ 
 PHP_FUNCTION(mysqli_real_connect)
 {
-	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE);
+	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE, FALSE);
 }
 /* }}} */
 

Modified: trunk/php6/ext/mysqli/mysqli_fe.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli_fe.c	2008-02-21 15:24:49 UTC (rev 1302)
+++ trunk/php6/ext/mysqli/mysqli_fe.c	2008-02-22 11:49:32 UTC (rev 1303)
@@ -217,7 +217,7 @@
 	PHP_FALIAS(set_local_infile_handler,mysqli_set_local_infile_handler,NULL)
 #endif
 	PHP_FALIAS(multi_query,mysqli_multi_query,NULL)
-	PHP_FALIAS(mysqli,mysqli_connect,NULL)
+	PHP_FALIAS(mysqli,mysqli_link_construct,NULL)
 	PHP_FALIAS(more_results,mysqli_more_results, NULL)
 	PHP_FALIAS(next_result, mysqli_next_result, NULL)
 	PHP_FALIAS(options,mysqli_options,NULL)

Modified: trunk/php6/ext/mysqli/mysqli_nonapi.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli_nonapi.c	2008-02-21 15:24:49 UTC (rev 1302)
+++ trunk/php6/ext/mysqli/mysqli_nonapi.c	2008-02-22 11:49:32 UTC (rev 1303)
@@ -33,7 +33,7 @@
 
 #define SAFE_STR(a) ((a)?a:"")
 
-void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect)
+void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect,
zend_bool in_ctor)
 {
 	MY_MYSQL			*mysql = NULL;
 	MYSQLI_RESOURCE		*mysqli_resource = NULL;
@@ -48,7 +48,7 @@
 	zend_rsrc_list_entry	*le;
 	mysqli_plist_entry *plist = NULL;
 
-	if (getThis() && !ZEND_NUM_ARGS()) {
+	if (getThis() && !ZEND_NUM_ARGS() && in_ctor) {
 		RETURN_NULL();
 	}
 	hostname = username = dbname = passwd = socket = NULL;
@@ -77,7 +77,6 @@
 			mysql = (MY_MYSQL *) ecalloc(1, sizeof(MY_MYSQL));
 		}
 		flags |= CLIENT_MULTI_RESULTS; /* needed for mysql_multi_query() */
-
 	} else {
 		/* We have flags too */
 		if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
"O|s&s&s&s&ls&l", &object, mysqli_link_class_entry,
@@ -85,6 +84,7 @@
 			&dbname, &dbname_len, UG(utf8_conv), &port, &socket, &socket_len,
UG(utf8_conv), &flags) == FAILURE) {
 			return;
 		}
+
 		mysqli_resource = ((mysqli_object *) zend_object_store_get_object(object
TSRMLS_CC))->ptr;
 		MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &object, "mysqli_link",
MYSQLI_STATUS_INITIALIZED);
 
@@ -295,11 +295,20 @@
    Open a connection to a mysql server */ 
 PHP_FUNCTION(mysqli_connect)
 {
-	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE);
+	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE, FALSE);
 }
 /* }}} */
 
 
+/* {{{ proto object mysqli_link_construct()
+  */ 
+PHP_FUNCTION(mysqli_link_construct)
+{
+	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE, TRUE);
+}
+/* }}} */
+
+
 /* {{{ proto int mysqli_connect_errno(void) U
    Returns the numerical value of the error message from last connect command */
 PHP_FUNCTION(mysqli_connect_errno)

Modified: trunk/php6/ext/mysqli/php_mysqli_structs.h
===================================================================
--- trunk/php6/ext/mysqli/php_mysqli_structs.h	2008-02-21 15:24:49 UTC (rev 1302)
+++ trunk/php6/ext/mysqli/php_mysqli_structs.h	2008-02-22 11:49:32 UTC (rev 1303)
@@ -366,7 +366,7 @@
 PHP_MYSQLI_API void mysqli_register_result(zval *return_value, void *result TSRMLS_DC);
 PHP_MYSQLI_API void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC);
 
-void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect);
+void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect,
zend_bool in_ctor);
 
 
 ZEND_BEGIN_MODULE_GLOBALS(mysqli)
@@ -463,6 +463,7 @@
 PHP_FUNCTION(mysqli_insert_id);
 PHP_FUNCTION(mysqli_init);
 PHP_FUNCTION(mysqli_kill);
+PHP_FUNCTION(mysqli_link_construct);
 PHP_FUNCTION(mysqli_set_local_infile_default);
 PHP_FUNCTION(mysqli_set_local_infile_handler);
 PHP_FUNCTION(mysqli_more_results);

Thread
PHP mysqlnd svn commit: r1303 - in trunk: php5/ext/mysqli php6/ext/mysqliahristov22 Feb