]> granicus.if.org Git - php/commitdiff
MFH: Proper ctor usage (Fix #46044)
authorJohannes Schlüter <johannes@php.net>
Wed, 7 Jan 2009 16:32:08 +0000 (16:32 +0000)
committerJohannes Schlüter <johannes@php.net>
Wed, 7 Jan 2009 16:32:08 +0000 (16:32 +0000)
NEWS
ext/mysqli/mysqli.c
ext/mysqli/tests/066.phpt
ext/mysqli/tests/bug34810.phpt
ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt
ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt
ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt

diff --git a/NEWS b/NEWS
index 7d03d49b5ed82f8fcf70865f1a0b6f742f0f4ac5..a9f6f55b5f9a9b8e0219c474280ca803b633d95a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,7 @@ PHP                                                                        NEWS
   Closure and SplFileInfo using exceptions). (Etienne)
 - Fixed bug #46268 (DateTime::modify() does not reset relative time values).
   (Derick)
+- Fixed bug #46044 (Mysqli - wrong error message). (Johannes)
 - Fixed bug #45991 (Ini files with the UTF-8 BOM are treated as invalid).
   (Scott)
 - Fixed bug #45989 (json_decode() doesn't return NULL on certain invalid
index ec344b218ccb450e85dd4601244585046f1f39e3..be847a514fcd3d4a8e97a873227e5677b4de2c47 100644 (file)
@@ -433,41 +433,6 @@ void mysqli_add_property(HashTable *h, const char *pname, size_t pname_len, mysq
 }
 /* }}} */
 
-static union _zend_function *php_mysqli_constructor_get(zval *object TSRMLS_DC)
-{
-       zend_class_entry * ce = Z_OBJCE_P(object);
-
-       if (ce != mysqli_link_class_entry && ce != mysqli_stmt_class_entry &&
-               ce != mysqli_result_class_entry && ce != mysqli_driver_class_entry && 
-               ce != mysqli_warning_class_entry) {
-               return zend_std_get_constructor(object TSRMLS_CC);
-       } else {
-               static zend_internal_function f;
-               mysqli_object *obj = (mysqli_object *)zend_objects_get_address(object TSRMLS_CC);
-
-               f.function_name = obj->zo.ce->name;
-               f.scope = obj->zo.ce;
-               f.arg_info = NULL;
-               f.num_args = 0;
-               f.fn_flags = 0;
-
-               f.type = ZEND_INTERNAL_FUNCTION;
-               if (obj->zo.ce == mysqli_link_class_entry) {
-                       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) {
-                       f.handler = ZEND_FN(mysqli_result_construct);
-               } else if (obj->zo.ce == mysqli_driver_class_entry) {
-                       f.handler = ZEND_FN(mysqli_driver_construct);
-               } else if (obj->zo.ce == mysqli_warning_class_entry) {
-                       f.handler = ZEND_MN(mysqli_warning___construct);
-               }
-
-               return (union _zend_function*)&f;
-       }
-}
-
 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);
@@ -707,7 +672,6 @@ PHP_MINIT_FUNCTION(mysqli)
        mysqli_object_handlers.read_property = mysqli_read_property;
        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;
 #if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
        mysqli_object_handlers.get_debug_info = mysqli_object_get_debug_info;
index 95c8c576f03e51613b58165568cad222189e0bdb..bdf253b7b0fd31e0a3df2e1f342ce87fa47961ac 100644 (file)
@@ -19,7 +19,7 @@ require_once('skipifconnectfailure.inc');
 
        $mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)");
 
-       if (($warning = new mysqli_warning($mysql))) {
+       if (($warning = $mysql->get_warnings())) {
                do {
                        printf("Warning\n");
                } while ($warning->next());
@@ -30,4 +30,4 @@ require_once('skipifconnectfailure.inc');
 ?>
 --EXPECT--
 Warning
-done!
\ No newline at end of file
+done!
index 9ddba2317398795f98366a07a3c9f612e9a4191d..05ecb69d059345a4311f9b1be12a088bbec3d068 100644 (file)
@@ -24,7 +24,7 @@ class DbConnection {
                $mysql->query("CREATE TABLE test_warnings (a int not null)");
                $mysql->query("SET sql_mode=''");
                $mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)");
-               var_dump(new mysqli_warning($mysql));
+               var_dump($mysql->get_warnings());
        } 
 } 
 
index cd4206510ed183a0bddc446b1002936d7797a435..981caaf32683067c29b15bbd6ae995b043793319 100644 (file)
@@ -187,9 +187,9 @@ mysqli_result->unknown = ''
 
 Constructor:
 
-Warning: mysqli_result::mysqli_result() expects parameter 2 to be long, string given in %s on line %d
+Warning: mysqli_result::__construct() expects parameter 2 to be long, string given in %s on line %d
 
-Warning: mysqli_result::mysqli_result() expects parameter 1 to be mysqli, string given in %s on line %d
+Warning: mysqli_result::__construct() expects parameter 1 to be mysqli, string given in %s on line %d
 done!
 --UEXPECTF--
 Parent class:
@@ -224,7 +224,7 @@ mysqli_result->unknown = ''
 
 Constructor:
 
-Warning: mysqli_result::mysqli_result() expects parameter 2 to be long, Unicode string given in %s on line %d
+Warning: mysqli_result::__construct() 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
+Warning: mysqli_result::__construct() expects parameter 1 to be mysqli, Unicode string given in %s on line %d
 done!
index dce75af3581a40f4f402883c8dbd6f7f1aaf741b..b2dddd382fdd716c00f34ad23bcca40835b4d64b 100644 (file)
@@ -187,7 +187,7 @@ stmt->unknown = '13'
 
 Prepare using the constructor:
 
-Warning: mysqli_stmt::mysqli_stmt() expects parameter 2 to be string, object given in %s on line %d
+Warning: mysqli_stmt::__construct() expects parameter 2 to be string, object given in %s on line %d
 done!
 --UEXPECTF--
 Parent class:
@@ -243,5 +243,5 @@ 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
+Warning: mysqli_stmt::__construct() expects parameter 2 to be binary string, object given in %s on line %d
 done!
index fd3060c8188a141909783dfb71b3da741cb9c224..5bd78a9c1586e59f71d5c541c06fd2b996c7eb2b 100644 (file)
@@ -22,5 +22,5 @@ require_once('skipifconnectfailure.inc');
        print "done!";
 ?>
 --EXPECTF--
-Warning: mysqli_result::mysqli_result(): Invalid value for resultmode in %s on line %d
+Warning: mysqli_result::__construct(): Invalid value for resultmode in %s on line %d
 done!