]> granicus.if.org Git - php/commitdiff
Proper ctor usage (Fix #46044)
authorJohannes Schlüter <johannes@php.net>
Wed, 7 Jan 2009 16:29:42 +0000 (16:29 +0000)
committerJohannes Schlüter <johannes@php.net>
Wed, 7 Jan 2009 16:29:42 +0000 (16:29 +0000)
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

index b03f870ae18f25d37dd43e38788cfc74fc2438a2..8921885a694acfa0d1d9e28a022802ad1d0d5aff 100644 (file)
@@ -424,41 +424,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);
@@ -713,7 +678,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;
        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 7b95a3ee1826774f021b43d028aecfe7cd97fed1..1844f475f6fe4b8df3e79814da426dad840fab4d 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 5d15a67f4a9d009cb24f146cb310397e95b7c4c2..cff3fc62b9b80bc6fbbc9fc4ae5e9ed09eea7828 100644 (file)
@@ -187,7 +187,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 7532b742c9f017872bc40df32923d7e091ac0174..2547e50103342d2b2c34df02aafda7e9d9e2c2cb 100644 (file)
@@ -187,5 +187,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!