From: Georg Richter Date: Fri, 17 Jun 2005 16:37:07 +0000 (+0000) Subject: MFH: fix for bug #33263 X-Git-Tag: php-5.0.5RC1~154 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a731ab4a894e24f26dd401844b6580142436f4c;p=php MFH: fix for bug #33263 --- diff --git a/NEWS b/NEWS index 3748bbb3ba..aee549593e 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ PHP NEWS - Fixed bug #33277 (private method accessed by child class). (Dmitry) - Fixed bug #33268 (iconv_strlen() works only with a parameter of < 3 in length). (Ilia) +- Fixed bug #33263 (mysqli_real_escape doesn't work in __construct) (Georg) - Fixed bug #33243 (ze1_compatibility_mode does not work as expected). (Dmitry) - Fixed bug #33242 (Mangled error message when stream fails). (Derick) - Fixed bug #33222 (segfault when CURL handle is closed in a callback). (Tony) diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index e9bf42d9b3..78844c78ab 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1032,7 +1032,13 @@ PHP_FUNCTION(mysqli_init) mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); mysqli_resource->ptr = (void *)mysql; - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry); + + if (!getThis()) { + MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry); + } else { + ((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource; + ((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->valid = 1; + } } /* }}} */ diff --git a/ext/mysqli/tests/bug33263.phpt b/ext/mysqli/tests/bug33263.phpt new file mode 100644 index 0000000000..44f9167c95 --- /dev/null +++ b/ext/mysqli/tests/bug33263.phpt @@ -0,0 +1,31 @@ +--TEST-- +bug #33263 (mysqli_real_connect in __construct) +--SKIPIF-- + +--FILE-- +prepare("SELECT DATABASE()"); + $stmt->execute(); + $stmt->bind_result($db); + $stmt->fetch(); + $stmt->close(); + + var_dump($db); + + $mysql->close(); +?> +--EXPECT-- +string(4) "test"