mirror of
https://github.com/php/php-src.git
synced 2024-11-25 10:54:15 +08:00
fix for bug #33263 (mysqli_real_escape doesn't work in __construct)
This commit is contained in:
parent
987f6f8fcf
commit
15563f8d91
@ -1030,7 +1030,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;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1743,7 +1749,7 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
|
||||
ulong attr;
|
||||
int rc;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olb", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode) == FAILURE) {
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
|
||||
|
31
ext/mysqli/tests/bug33263.phpt
Normal file
31
ext/mysqli/tests/bug33263.phpt
Normal file
@ -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"
|
Loading…
Reference in New Issue
Block a user