diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/mysqli/mysqli_api.c | 8 | ||||
-rw-r--r-- | ext/mysqli/tests/bug33263.phpt | 31 |
3 files changed, 39 insertions, 1 deletions
@@ -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-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + + include "connect.inc"; + + class test extends mysqli + { + public function __construct($host, $user, $passwd, $db) { + parent::init(); + parent::real_connect($host, $user, $passwd, $db); + } + } + + $mysql = new test($host, $user, $passwd, "test"); + + $stmt = $mysql->prepare("SELECT DATABASE()"); + $stmt->execute(); + $stmt->bind_result($db); + $stmt->fetch(); + $stmt->close(); + + var_dump($db); + + $mysql->close(); +?> +--EXPECT-- +string(4) "test" |