From c7e001a7366442abecfbd661d6807aa8ac32f052 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Schl=C3=BCter?= Date: Wed, 7 Jan 2009 16:29:42 +0000 Subject: [PATCH] Proper ctor usage (Fix #46044) --- ext/mysqli/mysqli.c | 36 ------------------- ext/mysqli/tests/066.phpt | 4 +-- ext/mysqli/tests/bug34810.phpt | 2 +- .../mysqli_class_mysqli_result_interface.phpt | 4 +-- .../mysqli_class_mysqli_stmt_interface.phpt | 2 +- .../mysqli_mysqli_result_invalid_mode.phpt | 2 +- 6 files changed, 7 insertions(+), 43 deletions(-) diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index b03f870ae1..8921885a69 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -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; diff --git a/ext/mysqli/tests/066.phpt b/ext/mysqli/tests/066.phpt index 95c8c576f0..bdf253b7b0 100644 --- a/ext/mysqli/tests/066.phpt +++ b/ext/mysqli/tests/066.phpt @@ -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! diff --git a/ext/mysqli/tests/bug34810.phpt b/ext/mysqli/tests/bug34810.phpt index 7b95a3ee18..1844f475f6 100644 --- a/ext/mysqli/tests/bug34810.phpt +++ b/ext/mysqli/tests/bug34810.phpt @@ -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()); } } diff --git a/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt index 5d15a67f4a..cff3fc62b9 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt @@ -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! diff --git a/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt index 7532b742c9..2547e50103 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt @@ -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! diff --git a/ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt b/ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt index fd3060c818..5bd78a9c15 100644 --- a/ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt +++ b/ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt @@ -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! -- 2.40.0