]> granicus.if.org Git - php/commitdiff
Fixed a bunch of bugs reported in
authorAndrey Hristov <andrey@php.net>
Tue, 18 Mar 2008 16:57:31 +0000 (16:57 +0000)
committerAndrey Hristov <andrey@php.net>
Tue, 18 Mar 2008 16:57:31 +0000 (16:57 +0000)
Bug #44352 mysqli_connect_error() false negative for host errors
From now on the mysqli object doesn't have that magic properties, like
error, which were readable but not visible through isset(), property_exists()
and var_dump(). All other ext/mysqli classes were fixed too.
Now it will be easier to debug mysqli based applications.

33 files changed:
NEWS
ext/mysqli/mysqli.c
ext/mysqli/mysqli_driver.c
ext/mysqli/mysqli_nonapi.c
ext/mysqli/mysqli_prop.c
ext/mysqli/mysqli_warning.c
ext/mysqli/php_mysqli_structs.h
ext/mysqli/tests/057.phpt
ext/mysqli/tests/bug34810.phpt
ext/mysqli/tests/connect.inc
ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt
ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt
ext/mysqli/tests/mysqli_class_mysqli_interface.phpt
ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt
ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt
ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt
ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt
ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt
ext/mysqli/tests/mysqli_connect_oo.phpt
ext/mysqli/tests/mysqli_constants.phpt
ext/mysqli/tests/mysqli_debug.phpt
ext/mysqli/tests/mysqli_debug_append.phpt
ext/mysqli/tests/mysqli_debug_control_string.phpt
ext/mysqli/tests/mysqli_debug_ini.phpt
ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt
ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt
ext/mysqli/tests/mysqli_kill.phpt
ext/mysqli/tests/mysqli_options.phpt
ext/mysqli/tests/mysqli_real_connect.phpt
ext/mysqli/tests/mysqli_result_references.phpt
ext/mysqli/tests/mysqli_stmt_attr_get.phpt
ext/mysqlnd/mysqlnd.c
ext/mysqlnd/mysqlnd_priv.h

diff --git a/NEWS b/NEWS
index 11c63ba269fad90fe2a68fc72b4425848c08bff6..0b3d6efc930a4044a77651fcb0d1bffff847f3fd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -138,6 +138,8 @@ PHP                                                                        NEWS
 - Fixed PECL bug #12431 (OCI8 ping functionality is broken). (Oracle Corp.)
 
 - Fixed bug #44414 (Incomplete reporting about abstract methods). (Dmitry)
+- Fixed bug #44352 (mysqli_connect_error() false negative for host errors).
+  (Andrey)
 - Fixed bug #44336 (Improve pcre UTF-8 string matching performance).
   (frode at coretrek dot com, Nuno)
 - Fixed bug #44257 (timelib_tz_lookup_table must use float for gmtoffset). 
index e385548d0bf19229d47c3d0ac1baa5e8dafe5710..eee29d39f55489c0a4de7a0468f74f6126d426c0 100644 (file)
@@ -12,7 +12,9 @@
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
-  | Author: Georg Richter <georg@php.net>                                |
+  | Authors: Georg Richter <georg@php.net>                               |
+  |          Andrey Hristov <andrey@php.net>                             |
+  |          Ulf Wendel <uw@php.net>                                     |
   +----------------------------------------------------------------------+
 
   $Id$ 
 ZEND_DECLARE_MODULE_GLOBALS(mysqli)
 static PHP_GINIT_FUNCTION(mysqli);
 
+#define MYSQLI_ADD_PROPERTIES(a,b) \
+{ \
+       int i = 0; \
+       while (b[i].pname != NULL) { \
+               mysqli_add_property((a), (b)[i].pname, (b)[i].pname_length, \
+                                                       (mysqli_read_t)(b)[i].r_func, (mysqli_write_t)(b)[i].w_func TSRMLS_CC); \
+               i++; \
+       }\
+}
+
+#define MYSQLI_ADD_PROPERTIES_INFO(a,b) \
+{ \
+       int i = 0; \
+       while (b[i].name != NULL) { \
+               zend_declare_property_null((a), (b)[i].name, (b)[i].name_length, ZEND_ACC_PUBLIC TSRMLS_CC); \
+               i++; \
+       }\
+}
+
+
+
 static zend_object_handlers mysqli_object_handlers;
 static HashTable classes;
 static HashTable mysqli_driver_properties;
@@ -54,10 +77,13 @@ MYSQLND_ZVAL_PCACHE *mysqli_mysqlnd_zval_cache;
 MYSQLND_QCACHE         *mysqli_mysqlnd_qcache;
 #endif
 
+
 typedef int (*mysqli_read_t)(mysqli_object *obj, zval **retval TSRMLS_DC);
 typedef int (*mysqli_write_t)(mysqli_object *obj, zval *newval TSRMLS_DC);
 
 typedef struct _mysqli_prop_handler {
+       char *name;
+       size_t name_len;
        mysqli_read_t read_func;
        mysqli_write_t write_func;
 } mysqli_prop_handler;
@@ -77,7 +103,7 @@ void php_mysqli_dtor_p_elements(void *data)
        mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT);
 }
 
-/* le_pmysqli dtor*/
+
 ZEND_RSRC_DTOR_FUNC(php_mysqli_dtor)
 {
        if (rsrc->ptr) {
@@ -400,13 +426,14 @@ void mysqli_write_property(zval *object, zval *member, zval *value TSRMLS_DC)
 /* }}} */
 
 /* {{{ void mysqli_add_property(HashTable *h, char *pname, mysqli_read_t r_func, mysqli_write_t w_func TSRMLS_DC) */
-void mysqli_add_property(HashTable *h, char *pname, mysqli_read_t r_func, mysqli_write_t w_func TSRMLS_DC) {
+void mysqli_add_property(HashTable *h, const char *pname, size_t pname_len, mysqli_read_t r_func, mysqli_write_t w_func TSRMLS_DC) {
        mysqli_prop_handler             p;
 
+       p.name = (char*) pname;
+       p.name_len = pname_len;
        p.read_func = (r_func) ? r_func : mysqli_read_na; 
        p.write_func = (w_func) ? w_func : mysqli_write_na;
-
-       zend_hash_add(h, pname, strlen(pname) + 1, &p, sizeof(mysqli_prop_handler), NULL);
+       zend_hash_add(h, pname, pname_len + 1, &p, sizeof(mysqli_prop_handler), NULL);
 }
 /* }}} */
 
@@ -445,6 +472,75 @@ static union _zend_function *php_mysqli_constructor_get(zval *object TSRMLS_DC)
        }
 }
 
+static int mysqli_object_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC) /* {{{ */
+{
+       mysqli_object *obj = (mysqli_object *)zend_objects_get_address(object TSRMLS_CC);
+       mysqli_prop_handler     p;
+       int ret = 0;
+
+       if (zend_hash_find(obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member) + 1, (void **)&p) == SUCCESS) {
+               switch (has_set_exists) {
+                       case 2:
+                               ret = 1;
+                               break;
+                       case 1: {
+                               zval *value = mysqli_read_property(object, member, BP_VAR_IS TSRMLS_CC);
+                               if (value != EG(uninitialized_zval_ptr)) {
+                                       convert_to_boolean(value);
+                                       ret = Z_BVAL_P(value)? 1:0;
+                                       /* refcount is 0 */
+                                       Z_ADDREF_P(value);
+                                       zval_ptr_dtor(&value);
+                               }
+                               break;
+                       }
+                       case 0:{
+                               zval *value = mysqli_read_property(object, member, BP_VAR_IS TSRMLS_CC);
+                               if (value != EG(uninitialized_zval_ptr)) {
+                                       ret = Z_TYPE_P(value) != IS_NULL? 1:0;
+                                       /* refcount is 0 */
+                                       Z_ADDREF_P(value);
+                                       zval_ptr_dtor(&value);
+                               }
+                               break;
+                       }
+                       default:
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for has_set_exists");        
+               }
+       }
+       return ret;
+} /* }}} */
+
+
+HashTable * mysqli_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
+{
+       mysqli_object *obj = (mysqli_object *)zend_objects_get_address(object TSRMLS_CC);
+       HashTable *retval, *props = obj->prop_handler;
+       HashPosition pos;
+       mysqli_prop_handler *entry;
+
+       ALLOC_HASHTABLE(retval);
+       ZEND_INIT_SYMTABLE_EX(retval, zend_hash_num_elements(props) + 1, 0);
+
+       zend_hash_internal_pointer_reset_ex(props, &pos);
+       while (zend_hash_get_current_data_ex(props, (void **)&entry, &pos) == SUCCESS) {
+               zval member;
+               zval *value;
+               INIT_ZVAL(member);
+               ZVAL_STRINGL(&member, entry->name, entry->name_len, 0); 
+               value = mysqli_read_property(object, &member, BP_VAR_IS TSRMLS_CC);
+               if (value != EG(uninitialized_zval_ptr)) {
+                       Z_ADDREF_P(value);
+                       zend_hash_add(retval, entry->name, entry->name_len + 1, &value, sizeof(zval *), NULL);
+               }
+               zend_hash_move_forward_ex(props, &pos);
+       }
+
+       *is_temp = 1;
+       return retval;
+}
+
+
 /* {{{ mysqli_objects_new
  */
 PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_type TSRMLS_DC)
@@ -461,7 +557,8 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
        intern->prop_handler = NULL;
 
        mysqli_base_class = class_type;
-       while (mysqli_base_class->type != ZEND_INTERNAL_CLASS && mysqli_base_class->parent != NULL) {
+       while (mysqli_base_class->type != ZEND_INTERNAL_CLASS &&
+                  mysqli_base_class->parent != NULL) {
                mysqli_base_class = mysqli_base_class->parent;
        }
        zend_hash_find(&classes, mysqli_base_class->name, mysqli_base_class->name_length + 1, 
@@ -495,7 +592,7 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
 
 
 /* Dependancies */
-const static zend_module_dep mysqli_deps[] = {
+static const  zend_module_dep mysqli_deps[] = {
 #if defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
        ZEND_MOD_REQUIRED("spl")
 #endif
@@ -562,7 +659,6 @@ static PHP_GINIT_FUNCTION(mysqli)
        mysqli_globals->num_active_persistent = 0;
        mysqli_globals->num_inactive_persistent = 0;
        mysqli_globals->max_links = -1;
-       mysqli_globals->max_links = -1;
        mysqli_globals->max_persistent = -1;
        mysqli_globals->allow_persistent = 1;
        mysqli_globals->default_port = 0;
@@ -611,6 +707,8 @@ PHP_MINIT_FUNCTION(mysqli)
        mysqli_object_handlers.write_property = mysqli_write_property;
        mysqli_object_handlers.get_property_ptr_ptr = std_hnd->get_property_ptr_ptr;
        mysqli_object_handlers.get_constructor = php_mysqli_constructor_get;
+       mysqli_object_handlers.has_property = mysqli_object_has_property;
+       mysqli_object_handlers.get_debug_info = mysqli_object_get_debug_info;
 
        zend_hash_init(&classes, 0, NULL, NULL, 1);
 
@@ -632,6 +730,7 @@ PHP_MINIT_FUNCTION(mysqli)
        ce = mysqli_driver_class_entry;
        zend_hash_init(&mysqli_driver_properties, 0, NULL, NULL, 1);
        MYSQLI_ADD_PROPERTIES(&mysqli_driver_properties, mysqli_driver_property_entries);
+       MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_driver_property_info_entries);
        zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_driver_properties, sizeof(mysqli_driver_properties), NULL);
        ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
 
@@ -639,6 +738,7 @@ PHP_MINIT_FUNCTION(mysqli)
        ce = mysqli_link_class_entry;
        zend_hash_init(&mysqli_link_properties, 0, NULL, NULL, 1);
        MYSQLI_ADD_PROPERTIES(&mysqli_link_properties, mysqli_link_property_entries);
+       MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_link_property_info_entries);
        zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_link_properties, sizeof(mysqli_link_properties), NULL);
 
        REGISTER_MYSQLI_CLASS_ENTRY("mysqli_warning", mysqli_warning_class_entry, mysqli_warning_methods);
@@ -646,18 +746,21 @@ PHP_MINIT_FUNCTION(mysqli)
        ce->ce_flags |= ZEND_ACC_FINAL_CLASS | ZEND_ACC_PROTECTED;
        zend_hash_init(&mysqli_warning_properties, 0, NULL, NULL, 1);
        MYSQLI_ADD_PROPERTIES(&mysqli_warning_properties, mysqli_warning_property_entries);
+       MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_warning_property_info_entries);
        zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_warning_properties, sizeof(mysqli_warning_properties), NULL);
 
        REGISTER_MYSQLI_CLASS_ENTRY("mysqli_result", mysqli_result_class_entry, mysqli_result_methods);
        ce = mysqli_result_class_entry;
        zend_hash_init(&mysqli_result_properties, 0, NULL, NULL, 1);
        MYSQLI_ADD_PROPERTIES(&mysqli_result_properties, mysqli_result_property_entries);
+       MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_result_property_info_entries);
        zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_result_properties, sizeof(mysqli_result_properties), NULL);
 
        REGISTER_MYSQLI_CLASS_ENTRY("mysqli_stmt", mysqli_stmt_class_entry, mysqli_stmt_methods);
        ce = mysqli_stmt_class_entry;
        zend_hash_init(&mysqli_stmt_properties, 0, NULL, NULL, 1);
        MYSQLI_ADD_PROPERTIES(&mysqli_stmt_properties, mysqli_stmt_property_entries);
+       MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_stmt_property_info_entries);
        zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_stmt_properties, sizeof(mysqli_stmt_properties), NULL);
        
        /* mysqli_options */
@@ -874,7 +977,9 @@ PHP_RSHUTDOWN_FUNCTION(mysqli)
  */
 PHP_MINFO_FUNCTION(mysqli)
 {
+#if defined(MYSQLI_USE_MYSQLND)
        char buf[32];
+#endif
 
        php_info_print_table_start();
        php_info_print_table_header(2, "MysqlI Support", "enabled");
@@ -914,7 +1019,7 @@ Parameters:
   object -> mysqli_stmt_init
   object, query -> mysqli_prepare
 */
-ZEND_FUNCTION(mysqli_stmt_construct)
+PHP_FUNCTION(mysqli_stmt_construct)
 {
        MY_MYSQL                        *mysql;
        zval                            *mysql_link;
@@ -944,7 +1049,7 @@ ZEND_FUNCTION(mysqli_stmt_construct)
                        stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
 
                        if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
-                               mysql_stmt_prepare(stmt->stmt, statement, statement_len);
+                               mysql_stmt_prepare(stmt->stmt, (char *)statement, statement_len);
                        }
                break;
                default:
@@ -970,7 +1075,7 @@ constructor for result object.
 Parameters: 
   object [, mode] -> mysqli_store/use_result
 */
-ZEND_FUNCTION(mysqli_result_construct)
+PHP_FUNCTION(mysqli_result_construct)
 {
        MY_MYSQL                        *mysql;
        MYSQL_RES                       *result = NULL;
@@ -1191,17 +1296,6 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
 }
 /* }}} */
 
-/* {{{ php_mysqli_set_error
- */
-PHP_MYSQLI_API void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC)
-{
-       MyG(error_no) = mysql_errno;
-       if (MyG(error_msg)) {
-               efree(MyG(error_msg));
-       }
-       MyG(error_msg) = estrdup(mysql_err);
-}
-/* }}} */
 
 #if !defined(MYSQLI_USE_MYSQLND)
 
@@ -1224,28 +1318,17 @@ if (a) {\
 }
 
 #define LOCAL_INFILE_ERROR_MSG(source,dest)\
-memset(source, 0, LOCAL_INFILE_ERROR_LEN);\
-memcpy(source, dest, MIN(strlen(dest), LOCAL_INFILE_ERROR_LEN-1));
+       memset(source, 0, LOCAL_INFILE_ERROR_LEN);\
+       memcpy(source, dest, MIN(strlen(dest), LOCAL_INFILE_ERROR_LEN-1));\
+       php_error_docref(NULL TSRMLS_CC, E_WARNING, dest);
 
-/* {{{ void php_set_local_infile_handler_default 
-*/
-void php_set_local_infile_handler_default(MY_MYSQL *mysql) {
-       /* register internal callback functions */
-       mysql_set_local_infile_handler(mysql->mysql, &php_local_infile_init, &php_local_infile_read,
-                               &php_local_infile_end, &php_local_infile_error, (void *)mysql);
-       if (mysql->li_read) {
-               zval_ptr_dtor(&mysql->li_read);
-               mysql->li_read = NULL;
-       }
-}
-/* }}} */
 
 /* {{{ php_local_infile_init
  */
-int php_local_infile_init(void **ptr, const char *filename, void *userdata)
+static int php_local_infile_init(void **ptr, const char *filename, void *userdata)
 {
        mysqli_local_infile                     *data;
-       MY_MYSQL                                        *mysql;
+       MY_MYSQL                                        *mysql;
        php_stream_context                      *context = NULL;
 
        TSRMLS_FETCH();
@@ -1282,9 +1365,9 @@ int php_local_infile_init(void **ptr, const char *filename, void *userdata)
 /* }}} */
 
 /* {{{ int php_local_infile_read */
-int php_local_infile_read(void *ptr, char *buf, uint buf_len)
+static int php_local_infile_read(void *ptr, char *buf, uint buf_len)
 {
-       mysqli_local_infile             *data;
+       mysqli_local_infile                     *data;
        MY_MYSQL                                        *mysql;
        zval                                            ***callback_args;
        zval                                            *retval;
@@ -1319,7 +1402,7 @@ int php_local_infile_read(void *ptr, char *buf, uint buf_len)
        ZVAL_STRING(*callback_args[1], "", 1);
        ZVAL_LONG(*callback_args[2], buf_len);
        ZVAL_STRING(*callback_args[3], "", 1);
-       
+
        if (call_user_function_ex(EG(function_table), 
                                                NULL,
                                                mysql->li_read,
@@ -1371,7 +1454,7 @@ int php_local_infile_read(void *ptr, char *buf, uint buf_len)
 
 /* {{{ php_local_infile_error
  */
-int php_local_infile_error(void *ptr, char *error_msg, uint error_msg_len)
+static int php_local_infile_error(void *ptr, char *error_msg, uint error_msg_len)
 {
        mysqli_local_infile *data = (mysqli_local_infile *) ptr;
 
@@ -1386,7 +1469,7 @@ int php_local_infile_error(void *ptr, char *error_msg, uint error_msg_len)
 
 /* {{{ php_local_infile_end
  */
-void php_local_infile_end(void *ptr)
+static void php_local_infile_end(void *ptr)
 {
        mysqli_local_infile             *data;
        MY_MYSQL                                *mysql;
@@ -1409,6 +1492,20 @@ void php_local_infile_end(void *ptr)
        return;
 }
 /* }}} */
+
+
+/* {{{ void php_set_local_infile_handler_default 
+*/
+void php_set_local_infile_handler_default(MY_MYSQL *mysql) {
+       /* register internal callback functions */
+       mysql_set_local_infile_handler(mysql->mysql, &php_local_infile_init, &php_local_infile_read,
+                               &php_local_infile_end, &php_local_infile_error, (void *)mysql);
+       if (mysql->li_read) {
+               zval_ptr_dtor(&mysql->li_read);
+               mysql->li_read = NULL;
+       }
+}
+/* }}} */
 #endif
 
 /*
index 0a4c5a2ec7c5757b95289036cf2331e765b9085a..4cbe6687726fb76b3d94887f6837136627ace6b8 100644 (file)
@@ -32,7 +32,7 @@
 #define MAP_PROPERTY_MYG_BOOL_READ(name, value) \
 static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \
 { \
-       ALLOC_ZVAL(*retval); \
+       MAKE_STD_ZVAL(*retval); \
        ZVAL_BOOL(*retval, MyG(value)); \
        return SUCCESS; \
 } \
@@ -47,7 +47,7 @@ static int name(mysqli_object *obj, zval *value TSRMLS_DC) \
 #define MAP_PROPERTY_MYG_LONG_READ(name, value) \
 static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \
 { \
-       ALLOC_ZVAL(*retval); \
+       MAKE_STD_ZVAL(*retval); \
        ZVAL_LONG(*retval, MyG(value)); \
        return SUCCESS; \
 } \
@@ -62,7 +62,7 @@ static int name(mysqli_object *obj, zval *value TSRMLS_DC) \
 #define MAP_PROPERTY_MYG_STRING_READ(name, value) \
 static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \
 { \
-       ALLOC_ZVAL(*retval); \
+       MAKE_STD_ZVAL(*retval); \
        ZVAL_STRING(*retval, MyG(value), 1); \
        return SUCCESS; \
 } \
@@ -87,7 +87,7 @@ static int driver_report_write(mysqli_object *obj, zval *value TSRMLS_DC)
 /* {{{ property driver_embedded_read */
 static int driver_embedded_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
-       ALLOC_ZVAL(*retval);
+       MAKE_STD_ZVAL(*retval);
 #ifdef HAVE_EMBEDDED_MYSQLI
        ZVAL_BOOL(*retval, 1);
 #else
@@ -100,7 +100,7 @@ static int driver_embedded_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 /* {{{ property driver_client_version_read */
 static int driver_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
-       ALLOC_ZVAL(*retval);
+       MAKE_STD_ZVAL(*retval);
        ZVAL_LONG(*retval, MYSQL_VERSION_ID);
        return SUCCESS;
 }
@@ -109,7 +109,7 @@ static int driver_client_version_read(mysqli_object *obj, zval **retval TSRMLS_D
 /* {{{ property driver_client_info_read */
 static int driver_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
-       ALLOC_ZVAL(*retval);
+       MAKE_STD_ZVAL(*retval);
        ZVAL_STRING(*retval, (char *)mysql_get_client_info(), 1);
        return SUCCESS;
 }
@@ -118,7 +118,7 @@ static int driver_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 /* {{{ property driver_driver_version_read */
 static int driver_driver_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
-       ALLOC_ZVAL(*retval);
+       MAKE_STD_ZVAL(*retval);
        ZVAL_LONG(*retval, MYSQLI_VERSION_ID);
        return SUCCESS;
 }
@@ -141,14 +141,27 @@ ZEND_FUNCTION(mysqli_driver_construct)
 }
 
 const mysqli_property_entry mysqli_driver_property_entries[] = {
-       {"client_info", driver_client_info_read, NULL},
-       {"client_version", driver_client_version_read, NULL},
-       {"driver_version", driver_driver_version_read, NULL},
-       {"embedded", driver_embedded_read, NULL},
-       {"reconnect", driver_reconnect_read, driver_reconnect_write},
-       {"report_mode", driver_report_read, driver_report_write},
-       {NULL, NULL, NULL}
+       {"client_info", sizeof("client_info") - 1, driver_client_info_read, NULL},
+       {"client_version", sizeof("client_version") - 1, driver_client_version_read, NULL},
+       {"driver_version", sizeof("driver_version") - 1, driver_driver_version_read, NULL},
+       {"embedded", sizeof("embedded") - 1, driver_embedded_read, NULL},
+       {"reconnect", sizeof("reconnect") - 1, driver_reconnect_read, driver_reconnect_write},
+       {"report_mode", sizeof("report_mode") - 1, driver_report_read, driver_report_write},
+       {NULL, 0, NULL, NULL}
+};
+
+/* {{{ mysqli_warning_property_info_entries */
+zend_property_info mysqli_driver_property_info_entries[] = {
+       {ZEND_ACC_PUBLIC, "client_info",        sizeof("client_info") - 1,              0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "client_version",     sizeof("client_version") - 1,   0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "driver_version",     sizeof("driver_version") - 1,   0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "embedded",           sizeof("embedded") - 1,                 0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "reconnect",          sizeof("reconnect") - 1,                0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "report_mode",        sizeof("report_mode") - 1,              0, NULL, 0, NULL},
+       {0,                                     NULL,                   0,                                                              0, NULL, 0, NULL},
 };
+/* }}} */
+
 
 /* {{{ mysqli_driver_methods[]
  */
index b4258a429c317428e8eeb327877382f5fe6dcc01..c44adcc778003d7fd4847d7ffdb532bec70dd707 100644 (file)
 
 #define SAFE_STR(a) ((a)?a:"")
 
+/* {{{ php_mysqli_set_error
+ */
+static void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC)
+{
+       MyG(error_no) = mysql_errno;
+       if (MyG(error_msg)) {
+               efree(MyG(error_msg));
+       }
+       MyG(error_msg) = estrdup(mysql_err);
+}
+/* }}} */
+
+
 void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect, zend_bool in_ctor)
 {
        MY_MYSQL                        *mysql = NULL;
@@ -215,7 +228,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
                                                port, socket, flags, MyG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL)
 #endif
        {
-               /* Save error messages */
+               /* Save error messages - for mysqli_connect_error() & mysqli_connect_errno() */
                php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC);
                php_mysqli_throw_sql_exception((char *)mysql_sqlstate(mysql->mysql), mysql_errno(mysql->mysql) TSRMLS_CC,
                                                                                "%s", mysql_error(mysql->mysql));
@@ -547,7 +560,6 @@ PHP_FUNCTION(mysqli_query)
                        break;
 #endif
        }
-
        if (!result) {
                php_mysqli_throw_sql_exception((char *)mysql_sqlstate(mysql->mysql), mysql_errno(mysql->mysql) TSRMLS_CC,
                                                                                "%s", mysql_error(mysql->mysql)); 
@@ -641,7 +653,7 @@ PHP_FUNCTION(mysqli_stmt_get_warnings)
        mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
        mysqli_resource->ptr = mysqli_resource->info = (void *)w;
        mysqli_resource->status = MYSQLI_STATUS_VALID;
-       MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry);    
+       MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry);
 }
 /* }}} */
 
@@ -652,10 +664,10 @@ PHP_FUNCTION(mysqli_set_charset)
 {
        MY_MYSQL                        *mysql;
        zval                            *mysql_link;
-       char                            *cs_name = NULL;
-       unsigned int            len;
+       char                            *cs_name;
+       int                                     csname_len;
 
-       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &cs_name, &len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &cs_name, &csname_len) == FAILURE) {
                return;
        }
        MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
index 1e06a694bfe5165d0cef79d1810aa8ff00819c62..cf8af39cbe154b7dd10f1d6d515e4be194466fd3 100644 (file)
@@ -38,7 +38,7 @@
 
 #define MYSQLI_GET_MYSQL(statusval) \
 MYSQL *p; \
-ALLOC_ZVAL(*retval);\
+MAKE_STD_ZVAL(*retval);\
 if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \
        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
        ZVAL_NULL(*retval);\
@@ -50,7 +50,7 @@ if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \
 
 #define MYSQLI_GET_RESULT(statusval) \
 MYSQL_RES *p; \
-ALLOC_ZVAL(*retval);\
+MAKE_STD_ZVAL(*retval);\
 if (!obj->ptr) { \
        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
        ZVAL_NULL(*retval);\
@@ -63,7 +63,7 @@ if (!obj->ptr) { \
 
 #define MYSQLI_GET_STMT(statusval) \
 MYSQL_STMT *p; \
-ALLOC_ZVAL(*retval);\
+MAKE_STD_ZVAL(*retval);\
 if (!obj->ptr) { \
        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
        ZVAL_NULL(*retval);\
@@ -114,7 +114,7 @@ static int __func(mysqli_object *obj, zval **retval TSRMLS_DC)\
 /* {{{ property link_client_version_read */
 static int link_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
-       ALLOC_ZVAL(*retval);
+       MAKE_STD_ZVAL(*retval);
        ZVAL_LONG(*retval, MYSQL_VERSION_ID);
        return SUCCESS;
 }
@@ -123,7 +123,7 @@ static int link_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 /* {{{ property link_client_info_read */
 static int link_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
-       ALLOC_ZVAL(*retval);
+       MAKE_STD_ZVAL(*retval);
        CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
        ZVAL_STRING(*retval, MYSQL_SERVER_VERSION, 1);
        return SUCCESS;
@@ -133,7 +133,7 @@ static int link_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 /* {{{ property link_connect_errno_read */
 static int link_connect_errno_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
-       ALLOC_ZVAL(*retval);
+       MAKE_STD_ZVAL(*retval);
        CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
        ZVAL_LONG(*retval, (long)MyG(error_no));
        return SUCCESS;
@@ -143,7 +143,7 @@ static int link_connect_errno_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 /* {{{ property link_connect_error_read */
 static int link_connect_error_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
-       ALLOC_ZVAL(*retval);
+       MAKE_STD_ZVAL(*retval);
        CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
        ZVAL_STRING(*retval, MyG(error_msg), 1);
        return SUCCESS;
@@ -156,7 +156,7 @@ static int link_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
        MY_MYSQL *mysql;
        my_ulonglong rc;
 
-       ALLOC_ZVAL(*retval); 
+       MAKE_STD_ZVAL(*retval); 
 
        mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
        
@@ -204,7 +204,7 @@ static int result_type_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
        MYSQL_RES *p;
 
-       ALLOC_ZVAL(*retval);
+       MAKE_STD_ZVAL(*retval);
        CHECK_STATUS(MYSQLI_STATUS_VALID);
        p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
 
@@ -223,7 +223,7 @@ static int result_lengths_read(mysqli_object *obj, zval **retval TSRMLS_DC)
        MYSQL_RES *p;
        ulong *ret;
 
-       ALLOC_ZVAL(*retval);
+       MAKE_STD_ZVAL(*retval);
 
        CHECK_STATUS(MYSQLI_STATUS_VALID);
        p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
@@ -255,7 +255,7 @@ static int stmt_id_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
        MY_STMT *p;
 
-       ALLOC_ZVAL(*retval); 
+       MAKE_STD_ZVAL(*retval); 
        CHECK_STATUS(MYSQLI_STATUS_VALID);
 
        p = (MY_STMT*)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
@@ -275,7 +275,7 @@ static int stmt_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
        MY_STMT *p;
        my_ulonglong rc;
 
-       ALLOC_ZVAL(*retval); 
+       MAKE_STD_ZVAL(*retval); 
        CHECK_STATUS(MYSQLI_STATUS_VALID);
 
        p = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
@@ -312,46 +312,92 @@ MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_sqlstate_read, mysql_stmt_sqlstate, MYSQLI_
 
 /* }}} */
 const mysqli_property_entry mysqli_link_property_entries[] = {
-       {"affected_rows", link_affected_rows_read, NULL},
-       {"client_info", link_client_info_read, NULL},
-       {"client_version", link_client_version_read, NULL},
-       {"connect_errno", link_connect_errno_read, NULL},
-       {"connect_error", link_connect_error_read, NULL},
-       {"errno", link_errno_read, NULL},
-       {"error", link_error_read, NULL},
-       {"field_count", link_field_count_read, NULL},
-       {"host_info", link_host_info_read, NULL},
-       {"info", link_info_read, NULL},
-       {"insert_id", link_insert_id_read, NULL},
-       {"server_info", link_server_info_read, NULL},
-       {"server_version", link_server_version_read, NULL},
-       {"sqlstate", link_sqlstate_read, NULL},
-       {"protocol_version", link_protocol_version_read, NULL},
-       {"thread_id", link_thread_id_read, NULL},
-       {"warning_count", link_warning_count_read, NULL},
-       {NULL, NULL, NULL}      
+       {"affected_rows",       sizeof("affected_rows") - 1,    link_affected_rows_read, NULL},
+       {"client_info",         sizeof("client_info") - 1,              link_client_info_read, NULL},
+       {"client_version",      sizeof("client_version") - 1,   link_client_version_read, NULL},
+       {"connect_errno",       sizeof("connect_errno") - 1,    link_connect_errno_read, NULL},
+       {"connect_error",       sizeof("connect_error") - 1,    link_connect_error_read, NULL},
+       {"errno",                       sizeof("errno") - 1,                    link_errno_read, NULL},
+       {"error",                       sizeof("error") - 1,                    link_error_read, NULL},
+       {"field_count",         sizeof("field_count") - 1,              link_field_count_read, NULL},
+       {"host_info",           sizeof("host_info") - 1,                link_host_info_read, NULL},
+       {"info",                        sizeof("info") - 1,                             link_info_read, NULL},
+       {"insert_id",           sizeof("insert_id") - 1,                link_insert_id_read, NULL},
+       {"server_info",         sizeof("server_info") - 1,              link_server_info_read, NULL},
+       {"server_version",      sizeof("server_version") - 1,   link_server_version_read, NULL},
+       {"sqlstate",            sizeof("sqlstate") - 1,                 link_sqlstate_read, NULL},
+       {"protocol_version",sizeof("protocol_version") - 1,     link_protocol_version_read, NULL},
+       {"thread_id",           sizeof("thread_id") - 1,                link_thread_id_read, NULL},
+       {"warning_count",       sizeof("warning_count") - 1,    link_warning_count_read, NULL},
+       {NULL, 0, NULL, NULL}   
 };
 
+/* should not be const, as it is patched during runtime */
+zend_property_info mysqli_link_property_info_entries[] = {
+       {ZEND_ACC_PUBLIC, "affected_rows",      sizeof("affected_rows") - 1,    0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "client_info",        sizeof("client_info") - 1,              0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "client_version",     sizeof("client_version") - 1,   0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "connect_errno",      sizeof("connect_errno") - 1,    0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "connect_error",      sizeof("connect_error") - 1,    0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "errno",                      sizeof("errno") - 1,                    0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "error",                      sizeof("error") - 1,                    0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "field_count",        sizeof("field_count") - 1,              0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "host_info",          sizeof("host_info") - 1,                0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "info",                       sizeof("info") - 1,                             0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "insert_id",          sizeof("insert_id") - 1,                0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "server_info",        sizeof("server_info") - 1,              0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "server_version",     sizeof("server_version") - 1,   0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "sqlstate",           sizeof("sqlstate") - 1,                 0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "protocol_version", sizeof("protocol_version")-1, 0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "thread_id",          sizeof("thread_id") - 1,                0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "warning_count",      sizeof("warning_count") - 1,    0, NULL, 0, NULL},
+       {0,                                     NULL,                   0,                                                              0, NULL, 0, NULL}       
+};
+
+
 const mysqli_property_entry mysqli_result_property_entries[] = {
-       {"current_field", result_current_field_read, NULL},
-       {"field_count", result_field_count_read, NULL},
-       {"lengths", result_lengths_read, NULL},
-       {"num_rows", result_num_rows_read, NULL},
-       {"type", result_type_read, NULL},
-       {NULL, NULL, NULL}
+       {"current_field",sizeof("current_field")-1,     result_current_field_read, NULL},
+       {"field_count", sizeof("field_count") - 1,      result_field_count_read, NULL},
+       {"lengths",     sizeof("lengths") - 1,          result_lengths_read, NULL},
+       {"num_rows",    sizeof("num_rows") - 1,         result_num_rows_read, NULL},
+       {"type",                sizeof("type") - 1,                     result_type_read, NULL},
+       {NULL, 0, NULL, NULL}
+};
+
+zend_property_info mysqli_result_property_info_entries[] = {
+       {ZEND_ACC_PUBLIC, "current_field",      sizeof("current_field")-1,      0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "field_count",        sizeof("field_count") - 1,      0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "lengths",            sizeof("lengths") - 1,          0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "num_rows",           sizeof("num_rows") - 1,         0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "type",                       sizeof("type") - 1,             0, NULL, 0, NULL},
+       {0,                                     NULL,                   0,                                                      0, NULL, 0, NULL}       
 };
 
 const mysqli_property_entry mysqli_stmt_property_entries[] = {
-       {"affected_rows", stmt_affected_rows_read, NULL},
-       {"insert_id", stmt_insert_id_read, NULL},
-       {"num_rows", stmt_num_rows_read, NULL},
-       {"param_count", stmt_param_count_read, NULL},
-       {"field_count", stmt_field_count_read, NULL},
-       {"errno", stmt_errno_read, NULL},
-       {"error", stmt_error_read, NULL},
-       {"sqlstate", stmt_sqlstate_read, NULL},
-       {"id", stmt_id_read, NULL},
-       {NULL, NULL, NULL}
+       {"affected_rows", sizeof("affected_rows")-1,stmt_affected_rows_read, NULL},
+       {"insert_id",   sizeof("insert_id") - 1,        stmt_insert_id_read, NULL},
+       {"num_rows",    sizeof("num_rows") - 1,         stmt_num_rows_read, NULL},
+       {"param_count", sizeof("param_count") - 1,      stmt_param_count_read, NULL},
+       {"field_count", sizeof("field_count") - 1,      stmt_field_count_read, NULL},
+       {"errno",               sizeof("errno") - 1,            stmt_errno_read, NULL},
+       {"error",               sizeof("error") - 1,            stmt_error_read, NULL},
+       {"sqlstate",    sizeof("sqlstate") - 1,         stmt_sqlstate_read, NULL},
+       {"id",                  sizeof("id") - 1,                       stmt_id_read, NULL},
+       {NULL, 0, NULL, NULL}
+};
+
+
+zend_property_info mysqli_stmt_property_info_entries[] = {
+       {ZEND_ACC_PUBLIC, "affected_rows", sizeof("affected_rows") - 1, 0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "insert_id",  sizeof("insert_id") - 1,                0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "num_rows",   sizeof("num_rows") - 1,                 0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "param_count",sizeof("param_count") - 1,              0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "field_count",sizeof("field_count") - 1,              0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "errno",              sizeof("errno") - 1,                    0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "error",              sizeof("error") - 1,                    0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "sqlstate",   sizeof("sqlstate") - 1,                 0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "id",                 sizeof("id") - 1,                               0, NULL, 0, NULL},
+       {0,                                     NULL,                   0,                                                      0, NULL, 0, NULL}       
 };
 
 /*
index 84612170348c4057d1344dcf5ea1b5636b16d504..125ef17c6043523483d17418bf40236c3efb38d7 100644 (file)
@@ -321,13 +321,23 @@ const zend_function_entry mysqli_warning_methods[] = {
 
 /* {{{ mysqli_warning_property_entries */
 const mysqli_property_entry mysqli_warning_property_entries[] = {
-       {"message", mysqli_warning_message, NULL},
-       {"sqlstate", mysqli_warning_sqlstate, NULL},
-       {"errno", mysqli_warning_errno, NULL},
-       {NULL, NULL, NULL}
+       {"message", sizeof("message") - 1, mysqli_warning_message, NULL},
+       {"sqlstate", sizeof("sqlstate") - 1, mysqli_warning_sqlstate, NULL},
+       {"errno", sizeof("errno") - 1, mysqli_warning_errno, NULL},
+       {NULL, 0, NULL, NULL}
 };
 /* }}} */
 
+/* {{{ mysqli_warning_property_info_entries */
+zend_property_info mysqli_warning_property_info_entries[] = {
+       {ZEND_ACC_PUBLIC, "message",    sizeof("message") - 1,  0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "sqlstate",   sizeof("sqlstate") - 1, 0, NULL, 0, NULL},
+       {ZEND_ACC_PUBLIC, "errno",              sizeof("errno") - 1,    0, NULL, 0, NULL},
+       {0,                                     NULL,                   0,                                      0, NULL, 0, NULL}       
+};
+/* }}} */
+
+
 /*
  * Local variables:
  * tab-width: 4
index 2dfdfc0e13a78f16ee2129bc7c46e4c7cf4e0b79..5cb16b3c3c7a44076341de5e1ed1fece1c1a50d2 100644 (file)
@@ -122,7 +122,8 @@ struct st_mysqli_warning {
 };
 
 typedef struct _mysqli_property_entry {
-       char *pname;
+       const char *pname;
+       size_t pname_length;
        int (*r_func)(mysqli_object *obj, zval **retval TSRMLS_DC);
        int (*w_func)(mysqli_object *obj, zval *value TSRMLS_DC);
 } mysqli_property_entry;
@@ -176,6 +177,12 @@ extern const mysqli_property_entry mysqli_stmt_property_entries[];
 extern const mysqli_property_entry mysqli_driver_property_entries[];
 extern const mysqli_property_entry mysqli_warning_property_entries[];
 
+extern zend_property_info mysqli_link_property_info_entries[];
+extern zend_property_info mysqli_result_property_info_entries[];
+extern zend_property_info mysqli_stmt_property_info_entries[];
+extern zend_property_info mysqli_driver_property_info_entries[];
+extern zend_property_info mysqli_warning_property_info_entries[];
+
 #ifdef MYSQLI_USE_MYSQLND
 extern MYSQLND_ZVAL_PCACHE     *mysqli_mysqlnd_zval_cache;
 extern MYSQLND_QCACHE          *mysqli_mysqlnd_qcache;
@@ -189,10 +196,6 @@ extern void php_clear_warnings(MYSQLI_WARNING *w);
 extern void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type);
 extern void php_mysqli_report_error(const char *sqlstate, int errorno, const char *error TSRMLS_DC);
 extern void php_mysqli_report_index(const char *query, unsigned int status TSRMLS_DC);
-extern int php_local_infile_init(void **, const char *, void *);
-extern int php_local_infile_read(void *, char *, uint);
-extern void php_local_infile_end(void *);
-extern int php_local_infile_error(void *, char *, uint);
 extern void php_set_local_infile_handler_default(MY_MYSQL *);
 extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...);
 extern zend_class_entry *mysqli_link_class_entry;
@@ -277,29 +280,15 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
 #define MYSQLI_RETURN_LONG_LONG(__val) \
 { \
        if ((__val) < LONG_MAX) {               \
-               RETURN_LONG((__val));           \
+               RETURN_LONG((long) (__val));            \
        } else {                                \
                char *ret;                      \
+               /* always used with my_ulonglong -> %llu */ \
                int l = spprintf(&ret, 0, "%llu", (__val));     \
                RETURN_STRINGL(ret, l, 0);              \
        }                                       \
 }
 
-#define MYSQLI_ADD_PROPERTIES(a,b) \
-{ \
-       int i = 0; \
-       while (b[i].pname != NULL) { \
-               mysqli_add_property(a, b[i].pname, (mysqli_read_t)b[i].r_func, (mysqli_write_t)b[i].w_func TSRMLS_CC); \
-               i++; \
-       }\
-}
-
-#if WIN32|WINNT
-#define SCLOSE(a) closesocket(a)
-#else
-#define SCLOSE(a) close(a)
-#endif
-
 #define MYSQLI_STORE_RESULT 0
 #define MYSQLI_USE_RESULT      1
 #ifdef MYSQLI_USE_MYSQLND
@@ -311,12 +300,6 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
 #define MYSQLI_NUM             2
 #define MYSQLI_BOTH            3
 
-/* for mysqli_bind_param */
-#define MYSQLI_BIND_INT                1
-#define MYSQLI_BIND_DOUBLE     2
-#define MYSQLI_BIND_STRING     3
-#define MYSQLI_BIND_SEND_DATA  4
-
 /* fetch types */
 #define FETCH_SIMPLE           1
 #define FETCH_RESULT           2
@@ -339,11 +322,6 @@ if ((MyG(report_mode) & MYSQLI_REPORT_ERROR) && mysql_stmt_errno(stmt)) { \
        php_mysqli_report_error(mysql_stmt_sqlstate(stmt), mysql_stmt_errno(stmt), mysql_stmt_error(stmt) TSRMLS_CC); \
 }
 
-PHP_MYSQLI_API void mysqli_register_link(zval *return_value, void *link TSRMLS_DC);
-PHP_MYSQLI_API void mysqli_register_stmt(zval *return_value, void *stmt TSRMLS_DC);
-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, zend_bool in_ctor);
 
 
@@ -375,9 +353,6 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqli)
 #endif
 ZEND_END_MODULE_GLOBALS(mysqli)
 
-#define MYSQLI_PROPERTY(a) extern int a(mysqli_object *obj, zval **retval TSRMLS_DC)
-
-MYSQLI_PROPERTY(my_prop_link_host);
 
 #ifdef ZTS
 #define MyG(v) TSRMG(mysqli_globals_id, zend_mysqli_globals *, v)
@@ -497,10 +472,10 @@ PHP_FUNCTION(mysqli_thread_safe);
 PHP_FUNCTION(mysqli_use_result);
 PHP_FUNCTION(mysqli_warning_count);
 
-ZEND_FUNCTION(mysqli_stmt_construct);
-ZEND_FUNCTION(mysqli_result_construct);
-ZEND_FUNCTION(mysqli_driver_construct);
-ZEND_METHOD(mysqli_warning,__construct);
+PHP_FUNCTION(mysqli_stmt_construct);
+PHP_FUNCTION(mysqli_result_construct);
+PHP_FUNCTION(mysqli_driver_construct);
+PHP_METHOD(mysqli_warning,__construct);
 
 #endif /* PHP_MYSQLI_STRUCTS.H */
 
index 1bb17b6961167cfd93910077d6507d4831503efd..a6a9cb6f975db7059051991126ffc21389b7854c 100644 (file)
@@ -62,6 +62,24 @@ require_once('skipifconnectfailure.inc');
 bool(true)
 bool(true)
 object(mysqli_stmt)#%d (%d) {
+  ["affected_rows"]=>
+  int(-1)
+  ["insert_id"]=>
+  int(0)
+  ["num_rows"]=>
+  int(0)
+  ["param_count"]=>
+  int(0)
+  ["field_count"]=>
+  int(1)
+  ["errno"]=>
+  int(0)
+  ["error"]=>
+  string(0) ""
+  ["sqlstate"]=>
+  string(5) "00000"
+  ["id"]=>
+  int(3)
 }
 bool(true)
 bool(false)
@@ -91,4 +109,4 @@ array(1) {
   [0]=>
   unicode(1) "1"
 }
-done!
\ No newline at end of file
+done!
index 8af0790e4983398288c9ff5d274a73e282e3709c..99bc7b6d7669b9970f009f79ae00b8a015547286 100644 (file)
@@ -16,7 +16,8 @@ class DbConnection {
                var_dump($link); 
                
                $link = mysqli_init();
-               var_dump($link);
+               /* @ is to supress 'Property access is not allowed yet' */
+               @var_dump($link);
                
                $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
                $mysql->query("DROP TABLE IF EXISTS test_warnings");
@@ -33,10 +34,84 @@ $db->connect();
 echo "Done\n";
 ?>
 --EXPECTF--    
-object(mysqli)#%d (0) {
+object(mysqli)#%d (%d) {
+  ["affected_rows"]=>
+  int(0)
+  ["client_info"]=>
+  string(%d) "%s"
+  ["client_version"]=>
+  int(%d)
+  ["connect_errno"]=>
+  int(0)
+  ["connect_error"]=>
+  string(0) ""
+  ["errno"]=>
+  int(0)
+  ["error"]=>
+  string(0) ""
+  ["field_count"]=>
+  int(0)
+  ["host_info"]=>
+  string(42) "MySQL host info: Localhost via UNIX socket"
+  ["info"]=>
+  NULL
+  ["insert_id"]=>
+  int(0)
+  ["server_info"]=>
+  string(%d) "%s"
+  ["server_version"]=>
+  int(%d)
+  ["sqlstate"]=>
+  string(5) "00000"
+  ["protocol_version"]=>
+  int(10)
+  ["thread_id"]=>
+  int(%d)
+  ["warning_count"]=>
+  int(0)
 }
-object(mysqli)#%d (0) {
+object(mysqli)#%d (%d) {
+  ["affected_rows"]=>
+  NULL
+  ["client_info"]=>
+  string(%d) "%s"
+  ["client_version"]=>
+  int(%d)
+  ["connect_errno"]=>
+  int(0)
+  ["connect_error"]=>
+  string(0) ""
+  ["errno"]=>
+  int(0)
+  ["error"]=>
+  string(0) ""
+  ["field_count"]=>
+  NULL
+  ["host_info"]=>
+  NULL
+  ["info"]=>
+  NULL
+  ["insert_id"]=>
+  NULL
+  ["server_info"]=>
+  NULL
+  ["server_version"]=>
+  NULL
+  ["sqlstate"]=>
+  NULL
+  ["protocol_version"]=>
+  NULL
+  ["thread_id"]=>
+  NULL
+  ["warning_count"]=>
+  NULL
 }
-object(mysqli_warning)#%d (0) {
+object(mysqli_warning)#%d (%d) {
+  ["message"]=>
+  string(25) "Column 'a' cannot be null"
+  ["sqlstate"]=>
+  string(5) "HY000"
+  ["errno"]=>
+  int(1048)
 }
 Done
index 135b47372ee9d2d5133ceaabfee635f1b43ae19e..9bb9836b725a61562c7c08103ba73729caeb91eb 100644 (file)
@@ -52,4 +52,4 @@
                        return FALSE;
                }
        }
-?>
+?>
\ No newline at end of file
index fb34d6ce52cca6cadd3a450a917dd0097c661b20..d6d2b755b4008c04157cce802f0a0939b2b08562 100644 (file)
@@ -46,13 +46,13 @@ require_once('skipifconnectfailure.inc');
                printf("ok\n");
 
        printf("\nClass variables:\n");
-       $variables = get_class_vars(get_class($driver));
+       $variables = array_keys(get_class_vars(get_class($driver)));
        sort($variables);
        foreach ($variables as $k => $var)
                printf("%s\n", $var);
 
        printf("\nObject variables:\n");
-       $variables = get_object_vars($driver);
+       $variables = array_keys(get_object_vars($driver));
        foreach ($variables as $k => $var)
                printf("%s\n", $var);
 
@@ -99,8 +99,20 @@ Methods:
 ok
 
 Class variables:
+client_info
+client_version
+driver_version
+embedded
+reconnect
+report_mode
 
 Object variables:
+client_info
+client_version
+driver_version
+embedded
+reconnect
+report_mode
 
 Magic, magic properties:
 driver->client_info = '%s'
@@ -112,4 +124,4 @@ driver->reconnect = ''
 
 Access to undefined properties:
 driver->unknown = ''
-done!
\ No newline at end of file
+done!
index 60db4a8fdf826c918daeb503c76002518f804bef..8a59549e50873cb04abb40439cd02b6a9573a73e 100644 (file)
@@ -37,4 +37,58 @@ isIteratable: no
 Modifiers: '%d'
 Parent Class: ''
 Extension: 'mysqli'
-done!
\ No newline at end of file
+
+Inspecting property 'client_info'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'client_version'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'driver_version'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'embedded'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'reconnect'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'report_mode'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+Default property 'client_info'
+Default property 'client_version'
+Default property 'driver_version'
+Default property 'embedded'
+Default property 'reconnect'
+Default property 'report_mode'
+done!
index 88a6a96dbde94c4aac858357d789edc39d38dab1..c1dc6a590a8ce806ace3f1c2f3fba25a0c0f3198 100644 (file)
@@ -92,13 +92,13 @@ require_once('skipifconnectfailure.inc');
                printf("ok\n");
 
        printf("\nClass variables:\n");
-       $variables = get_class_vars(get_class($mysqli));
+       $variables = array_keys(get_class_vars(get_class($mysqli)));
        sort($variables);
        foreach ($variables as $k => $var)
                printf("%s\n", $var);
 
        printf("\nObject variables:\n");
-       $variables = get_object_vars($mysqli);
+       $variables = array_keys(get_object_vars($mysqli));
        foreach ($variables as $k => $var)
                printf("%s\n", $var);
 
@@ -213,8 +213,42 @@ Methods:
 ok
 
 Class variables:
+affected_rows
+client_info
+client_version
+connect_errno
+connect_error
+errno
+error
+field_count
+host_info
+info
+insert_id
+protocol_version
+server_info
+server_version
+sqlstate
+thread_id
+warning_count
 
 Object variables:
+affected_rows
+client_info
+client_version
+connect_errno
+connect_error
+errno
+error
+field_count
+host_info
+info
+insert_id
+server_info
+server_version
+sqlstate
+protocol_version
+thread_id
+warning_count
 
 Magic, magic properties:
 mysqli->affected_rows = '%s'/integer ('%s'/integer)
@@ -250,8 +284,42 @@ Methods:
 ok
 
 Class variables:
+affected_rows
+client_info
+client_version
+connect_errno
+connect_error
+errno
+error
+field_count
+host_info
+info
+insert_id
+protocol_version
+server_info
+server_version
+sqlstate
+thread_id
+warning_count
 
 Object variables:
+affected_rows
+client_info
+client_version
+connect_errno
+connect_error
+errno
+error
+field_count
+host_info
+info
+insert_id
+server_info
+server_version
+sqlstate
+protocol_version
+thread_id
+warning_count
 
 Magic, magic properties:
 mysqli->affected_rows = '%s'/integer ('%s'/integer)
index 68ae1a725fdb05692b374f6434b011abea1682b3..51dc05ed5a404347714730534097354cddb0de0e 100644 (file)
@@ -24,7 +24,7 @@ if ($MYSQLND_VERSION < 576)
        require_once('reflection_tools.inc');
        $class = new ReflectionClass('mysqli');
        inspectClass($class);
-       print "done!";
+       print "done!\n";
 ?>
 --EXPECTF--
 Inspecting class 'mysqli'
@@ -646,4 +646,158 @@ returnsReference: no
 Modifiers: 256
 Number of Parameters: 0
 Number of Required Parameters: 0
+
+Inspecting property 'affected_rows'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'client_info'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'client_version'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'connect_errno'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'connect_error'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'errno'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'error'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'field_count'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'host_info'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'info'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'insert_id'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'protocol_version'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'server_info'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'server_version'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'sqlstate'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'thread_id'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'warning_count'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+Default property 'affected_rows'
+Default property 'client_info'
+Default property 'client_version'
+Default property 'connect_errno'
+Default property 'connect_error'
+Default property 'errno'
+Default property 'error'
+Default property 'field_count'
+Default property 'host_info'
+Default property 'info'
+Default property 'insert_id'
+Default property 'protocol_version'
+Default property 'server_info'
+Default property 'server_version'
+Default property 'sqlstate'
+Default property 'thread_id'
+Default property 'warning_count'
 done!
+
index 10edac8f0e6118639cfb333a7d8953a0dd9531d7..cd4206510ed183a0bddc446b1002936d7797a435 100644 (file)
@@ -67,13 +67,13 @@ require_once('skipifconnectfailure.inc');
 
 
        printf("\nClass variables:\n");
-       $variables = get_class_vars(get_class($mysqli_result));
+       $variables = array_keys(get_class_vars(get_class($mysqli_result)));
        sort($variables);
        foreach ($variables as $k => $var)
                printf("%s\n", $var);
 
        printf("\nObject variables:\n");
-       $variables = get_object_vars($mysqli_result);
+       $variables = array_keys(get_object_vars($mysqli_result));
        foreach ($variables as $k => $var)
                printf("%s\n", $var);
 
@@ -162,8 +162,18 @@ Methods:
 ok
 
 Class variables:
+current_field
+field_count
+lengths
+num_rows
+type
 
 Object variables:
+current_field
+field_count
+lengths
+num_rows
+type
 
 Magic, magic properties:
 mysqli_result->current_field = '0'/integer ('0'/integer)
@@ -189,8 +199,18 @@ Methods:
 ok
 
 Class variables:
+current_field
+field_count
+lengths
+num_rows
+type
 
 Object variables:
+current_field
+field_count
+lengths
+num_rows
+type
 
 Magic, magic properties:
 mysqli_result->current_field = '0'/integer ('0'/integer)
@@ -207,4 +227,4 @@ Constructor:
 Warning: mysqli_result::mysqli_result() expects parameter 2 to be long, Unicode string given in %s on line %d
 
 Warning: mysqli_result::mysqli_result() expects parameter 1 to be mysqli, Unicode string given in %s on line %d
-done!
\ No newline at end of file
+done!
index dd27e2e1d233a2c878d85810e805339a911816b8..5f26d1eb5d9dc238d37103f5c5995076c2cafcda 100644 (file)
@@ -279,4 +279,49 @@ returnsReference: no
 Modifiers: %d
 Number of Parameters: 0
 Number of Required Parameters: 0
-done!
\ No newline at end of file
+
+Inspecting property 'current_field'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'field_count'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'lengths'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'num_rows'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'type'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+Default property 'current_field'
+Default property 'field_count'
+Default property 'lengths'
+Default property 'num_rows'
+Default property 'type'
+done!
index 812399de80369270f635ef0813da5ad5a82bcce2..cc604aaef0d002ea5b778a05cd7118bdce870bf9 100644 (file)
@@ -67,13 +67,13 @@ Interface of the class mysqli_stmt
                printf("ok\n");
 
        printf("\nClass variables:\n");
-       $variables = get_class_vars(get_class($stmt));
+       $variables = array_keys(get_class_vars(get_class($stmt)));
        sort($variables);
        foreach ($variables as $k => $var)
                printf("%s\n", $var);
 
        printf("\nObject variables:\n");
-       $variables = get_object_vars($stmt);
+       $variables = array_keys(get_object_vars($stmt));
        foreach ($variables as $k => $var)
                printf("%s\n", $var);
 
@@ -138,8 +138,26 @@ Methods:
 ok
 
 Class variables:
+affected_rows
+errno
+error
+field_count
+id
+insert_id
+num_rows
+param_count
+sqlstate
 
 Object variables:
+affected_rows
+insert_id
+num_rows
+param_count
+field_count
+errno
+error
+sqlstate
+id
 
 Magic, magic properties:
 
@@ -176,8 +194,26 @@ Methods:
 ok
 
 Class variables:
+affected_rows
+errno
+error
+field_count
+id
+insert_id
+num_rows
+param_count
+sqlstate
 
 Object variables:
+affected_rows
+insert_id
+num_rows
+param_count
+field_count
+errno
+error
+sqlstate
+id
 
 Magic, magic properties:
 
@@ -205,4 +241,4 @@ stmt->unknown = '13'
 Prepare using the constructor:
 
 Warning: mysqli_stmt::mysqli_stmt() expects parameter 2 to be binary string, object given in %s on line %d
-done!
\ No newline at end of file
+done!
index 738aa46ed09006aca02a142338c3a77fbf0fa98f..cb690437ae39cf9703fe4d9c9c3a114cea6dfaba 100644 (file)
@@ -24,7 +24,7 @@ if ($MYSQLND_VERSION < 576)
        require_once('reflection_tools.inc');
        $class = new ReflectionClass('mysqli_warning');
        inspectClass($class);
-       print "done!";
+       print "done!\n";
 ?>
 --EXPECTF--
 Inspecting class 'mysqli_warning'
@@ -86,4 +86,31 @@ returnsReference: no
 Modifiers: %d
 Number of Parameters: 0
 Number of Required Parameters: 0
-done!
\ No newline at end of file
+
+Inspecting property 'errno'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'message'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'sqlstate'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+Default property 'errno'
+Default property 'message'
+Default property 'sqlstate'
+done!
index 3c76b6788ce6029e72e6b2ab782665946e7f5b0d..63660fd2b633a5acceb5b8036a45b90f03c9a360 100644 (file)
@@ -50,17 +50,32 @@ new mysqli()
 
        ini_set('mysqli.default_host', $host);
        if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) {
-               printf("[008] Usage of mysqli.default_host failed\n") ;
+               printf("[012] Failed to create mysqli object\n");
        } else {
-               $mysqli->close();
+               // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection!
+                       // We had long discussions on this and found that the ext/mysqli API as
+                       // such is broken. As we can't fix it, we document how it has behaved from
+                       // the first day on. And that's: no connection.
+                       if (NULL !== ($tmp = @$mysqli->query('SELECT 1'))) {
+                               printf("[013] There shall be no connection!\n");
+                               $mysqli->close();
+                       }
        }
 
        if ($IS_MYSQLND) {
                ini_set('mysqli.default_host', 'p:' . $host);
-               if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) {
-                       printf("[008b] Usage of mysqli.default_host failed\n") ;
+               if (!is_object($mysqli = new mysqli())) {
+                       // Due to an API flaw this shall not connect
+                       printf("[010] Failed to create mysqli object\n");
                } else {
-                       $mysqli->close();
+                       // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection!
+                       // We had long discussions on this and found that the ext/mysqli API as
+                       // such is broken. As we can't fix it, we document how it has behaved from
+                       // the first day on. And that's: no connection.
+                       if (NULL !== ($tmp = @$mysqli->query('SELECT 1'))) {
+                               printf("[011] There shall be no connection!\n");
+                               $mysqli->close();
+                       }
                }
        }
 
@@ -130,8 +145,6 @@ new mysqli()
 ?>
 --EXPECTF--
 Warning: mysqli::mysqli(): (%d/%d): Access denied for user '%sunknown%s'@'%s' (using password: %s) in %s on line %d
-
-Warning: mysqli::close(): Couldn't fetch mysqli in %s on line %d
 ... and now Exceptions
 Access denied for user '%s'@'%s' (using password: %s)
 done!
\ No newline at end of file
index 28573f71a96fc4d2efc89533d90c0d9e916cd50a..6cd09c652be0a795bb53f5c641d193e7014ae378 100644 (file)
@@ -93,13 +93,13 @@ require_once('skipifconnectfailure.inc');
                $expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true;
                $expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true;
                $expected_constants['MYSQLI_DEBUG_TRACE_ENABLED'] = true;
-               
+
        } else {
                $version = mysqli_get_client_version();
        }
 
        if (($version > 51122 && $version < 60000) || ($version > 60003) || $IS_MYSQLND) {
-               $expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true;        
+               $expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true;
        }
 
        if ($version > 50002) {
index 38e38d14d35cf8d6b9118e06746e76974b5ff3cd..a95fb20972956da5fec6dfd5dbf8625fdd6124a7 100644 (file)
@@ -8,6 +8,12 @@ require_once('skipifconnectfailure.inc');
 
 if (!function_exists('mysqli_debug'))
        die("skip: mysqli_debug() not available");
+
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+       die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+       die("skip: debug functionality not enabled");
 ?>
 --FILE--
 <?php
index 7b67d527d6ac85edacbe6c0cbfc25b576c95ea6d..c9de3c867123fbabc19f99bdc49cbb21104c93be 100644 (file)
@@ -8,6 +8,12 @@ require_once('skipifconnectfailure.inc');
 
 if (!function_exists('mysqli_debug'))
        die("skip: mysqli_debug() not available");
+
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+       die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+       die("skip: debug functionality not enabled");
 ?>
 --FILE--
 <?php
index 5df3c6068ee82691990e75fc02a3a7ab303d0038..13206ed4a357a48f7482d36a2621594c0c699017 100644 (file)
@@ -8,6 +8,12 @@ require_once('skipifconnectfailure.inc');
 
 if (!function_exists('mysqli_debug'))
        die("skip: mysqli_debug() not available");
+
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+       die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+       die("skip: debug functionality not enabled");
 ?>
 --FILE--
 <?php
index 2d1bb08a8e32dbddc396c5145e76814f2786357b..7a94b40226ec521033607a901a00375fdfb1f05a 100644 (file)
@@ -8,6 +8,12 @@ require_once('skipifemb.inc');
 if (!function_exists('mysqli_debug'))
        die("skip mysqli_debug() not available");
 
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+       die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+       die("skip: debug functionality not enabled");
+
 require_once('connect.inc');
 if (!$IS_MYSQLND || ($MYSQLND_VERSION < 940))
        die("skip needs mysqlnd version/revision 940+");
index 87047a96d4e122b76de68eb77bf5955c500c67c5..8a4d3a184ea0a127a9ce727ba205b76f3b60f2a6 100644 (file)
@@ -8,6 +8,12 @@ require_once('skipifconnectfailure.inc');
 
 if (!function_exists('mysqli_debug'))
        die("skip: mysqli_debug() not available");
+
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+       die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+       die("skip: debug functionality not enabled");
 ?>
 --FILE--
 <?php
index 1fd5b6a6cb093ab97c9dbfadb02c988c4995aebb..34ca27be48f1eccfe14fcbfc058db015eec71009 100644 (file)
@@ -10,6 +10,12 @@ require_once('connect.inc');
 if (!function_exists('mysqli_debug'))
        die("skip mysqli_debug() not available");
 
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+       die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+       die("skip: debug functionality not enabled");
+
 if (!$IS_MYSQLND)
        die("skip mysqlnd only test");
 ?>
index 2987e8e50dcf17512d88012b6065da119307724a..44a1828d4e7fc08ac240c59848519438981d08c2 100644 (file)
@@ -68,7 +68,41 @@ require_once('skipifconnectfailure.inc');
 Warning: mysqli_kill(): processid should have positive value in %s on line %d
 string(%d) "%s"
 bool(false)
-object(mysqli)#%d (0) {
+object(mysqli)#%d (%d) {
+  ["affected_rows"]=>
+  int(-1)
+  ["client_info"]=>
+  string(%d) "%s"
+  ["client_version"]=>
+  int(%d)
+  ["connect_errno"]=>
+  int(0)
+  ["connect_error"]=>
+  string(0) ""
+  ["errno"]=>
+  int(2006)
+  ["error"]=>
+  string(26) "MySQL server has gone away"
+  ["field_count"]=>
+  int(0)
+  ["host_info"]=>
+  string(42) "MySQL host info: Localhost via UNIX socket"
+  ["info"]=>
+  string(38) "Records: 6  Duplicates: 0  Warnings: 0"
+  ["insert_id"]=>
+  int(0)
+  ["server_info"]=>
+  string(%d) "%s"
+  ["server_version"]=>
+  int(%d)
+  ["sqlstate"]=>
+  string(5) "HY000"
+  ["protocol_version"]=>
+  int(10)
+  ["thread_id"]=>
+  int(%d)
+  ["warning_count"]=>
+  int(0)
 }
 
 Warning: mysqli_kill(): processid should have positive value in %s on line %d
@@ -93,4 +127,4 @@ array(1) {
 }
 
 Warning: mysqli_kill(): processid should have positive value in %s on line %d
-done!
\ No newline at end of file
+done!
index 1bfa5faa3fead92e96c7a95251f8857c4689b22d..c15fbbec9f9295289ce84fb7b39781abad567a1a 100644 (file)
@@ -1,14 +1,33 @@
 --TEST--
 mysqli_options()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
        include "connect.inc";
+
+/*
+TODO: ext/mysqli might lack support for those options which are available
+with the libmysql C call mysql_options(). Not sure which of them make
+sense to have in PHP and not even sure which of them might be available
+already through other measures.
+
+       MYSQL_OPT_COMPRESS (argument: not used) --> Andrey/Ulf: bug, should be added
+       ? MYSQL_OPT_NAMED_PIPE (argument: not used) ?
+       MYSQL_OPT_READ_TIMEOUT (argument type: unsigned int *) --> Andrey/Ulf: bug, should be added
+       MYSQL_OPT_RECONNECT (argument type: my_bool *) -->  Andrey/Ulf: might be security risk to have
+       MYSQL_OPT_SSL_VERIFY_SERVER_CERT (argument type: my_bool *) --> Andrey/Ulf: might be security risk to have
+       MYSQL_OPT_WRITE_TIMEOUT (argument type: unsigned int *) --> Andrey/Ulf: bug, should be added
+       MYSQL_REPORT_DATA_TRUNCATION (argument type: my_bool *) --> Andrey: bug, although truncation might only happen with libmysql not with mysqlnd
+       MYSQL_SECURE_AUTH (argument type: my_bool *) --> Ulf: let's say deprecated, no bug
+       ? MYSQL_SET_CHARSET_DIR (argument type: char *) ?
+       MYSQL_SHARED_MEMORY_BASE_NAME (argument type: char *)
+*/
+
        $valid_options = array(  MYSQLI_READ_DEFAULT_GROUP, MYSQLI_READ_DEFAULT_FILE,
                MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE,
                MYSQLI_INIT_COMMAND, MYSQLI_READ_DEFAULT_GROUP,
index b8c033c7238f845db515f8161526ae92bc117a0d..646686c02772eb7237de91bd3f84bd6b09b7bd64 100644 (file)
@@ -163,7 +163,7 @@ require_once('skipifconnectfailure.inc');
                }
        }
 
-       var_dump($link);
+       @var_dump($link);
 
        if (NULL === ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
                printf("[026] Expecting not NULL, got %s/%s\n", gettype($tmp), $tmp);
@@ -173,5 +173,39 @@ require_once('skipifconnectfailure.inc');
 --EXPECTF--
 Warning: mysqli_real_connect(): (%d/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d
 object(mysqli)#%d (%d) {
+  ["affected_rows"]=>
+  NULL
+  ["client_info"]=>
+  string(%d) "%s"
+  ["client_version"]=>
+  int(%d)
+  ["connect_errno"]=>
+  int(%d)
+  ["connect_error"]=>
+  string(%d) "%s"
+  ["errno"]=>
+  int(%d)
+  ["error"]=>
+  string(%d) "%s"
+  ["field_count"]=>
+  NULL
+  ["host_info"]=>
+  NULL
+  ["info"]=>
+  NULL
+  ["insert_id"]=>
+  NULL
+  ["server_info"]=>
+  NULL
+  ["server_version"]=>
+  NULL
+  ["sqlstate"]=>
+  NULL
+  ["protocol_version"]=>
+  NULL
+  ["thread_id"]=>
+  NULL
+  ["warning_count"]=>
+  NULL
 }
 done!
index 513d1d07b800c138768da7eee22126ad592e2f70..291c42ca3b3a8eeaa9f8db9ce3c480d64f1b3382 100644 (file)
@@ -59,7 +59,7 @@ require_once('skipifconnectfailure.inc');
 
        $references[$idx++] = &$res;
        mysqli_free_result($res);
-       debug_zval_dump($references);
+       @debug_zval_dump($references);
 
        if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) ||
                        !($res = mysqli_use_result($link)))
@@ -199,4 +199,4 @@ array(1) refcount(2){
     unicode(1) "a" { 0061 } refcount(1)
   }
 }
-done!
\ No newline at end of file
+done!
index d17e736f054ae1071bbee990adfcac0c6f385357..6156936f34dde099ec4ae8cf3cdb5610051e36c2 100644 (file)
@@ -63,4 +63,4 @@ require_once('skipifconnectfailure.inc');
        print "done!";
 ?>
 --EXPECTF--
-done!
\ No newline at end of file
+done!
index bda568bd19bc5ce16eff26d029c7d58b8da458df..b3ac202441fcc167442a11b8a8a2780d79fd6b04 100644 (file)
@@ -805,8 +805,7 @@ err:
 
        if (errstr) {
                DBG_ERR_FMT("[%d] %.64s (trying to connect via %s)", errcode, errstr, conn->scheme);
-               SET_CLIENT_ERROR(conn->error_info, errcode, UNKNOWN_SQLSTATE, errstr);
-
+               SET_CLIENT_ERROR(conn->error_info, errcode? errcode:CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, errstr);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "[%d] %.64s (trying to connect via %s)", errcode, errstr, conn->scheme);
 
                mnd_efree(errstr);
index 337d4186e63e37f4bc0746e64d19660d1e7da80a..7ffbc67eaf44a5b31509d82fc1958d733a3a701a 100644 (file)
 
 #define SET_CLIENT_ERROR(error_info, a, b, c) \
        { \
-               error_info.error_no = a; \
-               strlcpy(error_info.sqlstate, b, sizeof(error_info.sqlstate)); \
-               strlcpy(error_info.error, c, sizeof(error_info.error)); \
+               error_info.error_no = (a); \
+               strlcpy(error_info.sqlstate, (b), sizeof(error_info.sqlstate)); \
+               strlcpy(error_info.error, (c), sizeof(error_info.error)); \
        }
 
 #define SET_STMT_ERROR(stmt, a, b, c)  SET_CLIENT_ERROR(stmt->error_info, a, b, c)