]> granicus.if.org Git - php/commitdiff
MFH: fix for bug #33263
authorGeorg Richter <georg@php.net>
Fri, 17 Jun 2005 16:37:07 +0000 (16:37 +0000)
committerGeorg Richter <georg@php.net>
Fri, 17 Jun 2005 16:37:07 +0000 (16:37 +0000)
NEWS
ext/mysqli/mysqli_api.c
ext/mysqli/tests/bug33263.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 3748bbb3ba162b9f1ab04e02c9966b6568a24ce3..aee549593ec267f1c2a301faa5ceb6a4c49655b4 100644 (file)
--- 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)
index e9bf42d9b3926fcac232c232ba9d126e34918b65..78844c78ab56a810858e95a8c407d223d51c289a 100644 (file)
@@ -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 (file)
index 0000000..44f9167
--- /dev/null
@@ -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"