mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fixed bug #70389 (PDO constructor changes unrelated variables)
This commit is contained in:
parent
00eebd7a47
commit
ef1bd8f0e6
4 changed files with 56 additions and 4 deletions
3
NEWS
3
NEWS
|
@ -10,6 +10,9 @@ PHP NEWS
|
|||
. Fixed bug #55259 (openssl extension does not get the DH parameters from
|
||||
DH key resource). (Jakub Zelenka)
|
||||
|
||||
- PDO:
|
||||
- Fixed bug #70389 (PDO constructor changes unrelated variables). (Laruence)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #67131 (setcookie() conditional for empty values not met). (cmb)
|
||||
|
||||
|
|
|
@ -289,8 +289,14 @@ static PHP_METHOD(PDO, dbh_constructor)
|
|||
Z_STRVAL_PP(v));
|
||||
is_persistent = 1;
|
||||
} else {
|
||||
convert_to_long_ex(v);
|
||||
is_persistent = Z_LVAL_PP(v) ? 1 : 0;
|
||||
if (Z_TYPE_PP(v) != IS_LONG) {
|
||||
zval tmp = **v;
|
||||
zval_copy_ctor(&tmp);
|
||||
convert_to_long(&tmp);
|
||||
is_persistent = Z_LVAL(tmp)? 1 : 0;
|
||||
} else {
|
||||
is_persistent = Z_LVAL_PP(v)? 1 : 0;
|
||||
}
|
||||
plen = spprintf(&hashkey, 0, "PDO:DBH:DSN=%s:%s:%s", data_source,
|
||||
username ? username : "",
|
||||
password ? password : "");
|
||||
|
|
|
@ -197,7 +197,12 @@ static inline long pdo_attr_lval(zval *options, enum pdo_attribute_type option_n
|
|||
zval **v;
|
||||
|
||||
if (options && SUCCESS == zend_hash_index_find(Z_ARRVAL_P(options), option_name, (void**)&v)) {
|
||||
convert_to_long_ex(v);
|
||||
if (Z_TYPE_PP(v) != IS_LONG) {
|
||||
zval tmp = **v;
|
||||
zval_copy_ctor(&tmp);
|
||||
convert_to_long(&tmp);
|
||||
return Z_LVAL(tmp);
|
||||
}
|
||||
return Z_LVAL_PP(v);
|
||||
}
|
||||
return defval;
|
||||
|
@ -207,7 +212,12 @@ static inline char *pdo_attr_strval(zval *options, enum pdo_attribute_type optio
|
|||
zval **v;
|
||||
|
||||
if (options && SUCCESS == zend_hash_index_find(Z_ARRVAL_P(options), option_name, (void**)&v)) {
|
||||
convert_to_string_ex(v);
|
||||
if (Z_TYPE_PP(v) != IS_STRING) {
|
||||
zval tmp = **v;
|
||||
zval_copy_ctor(&tmp);
|
||||
convert_to_string(&tmp);
|
||||
return Z_STRVAL(tmp);
|
||||
}
|
||||
return estrndup(Z_STRVAL_PP(v), Z_STRLEN_PP(v));
|
||||
}
|
||||
return defval ? estrdup(defval) : NULL;
|
||||
|
|
33
ext/pdo_mysql/tests/bug70389.phpt
Normal file
33
ext/pdo_mysql/tests/bug70389.phpt
Normal file
|
@ -0,0 +1,33 @@
|
|||
--TEST--
|
||||
Bug #70389 (PDO constructor changes unrelated variables)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require(dirname(__FILE__). DIRECTORY_SEPARATOR . 'config.inc');
|
||||
$flags = [
|
||||
PDO::MYSQL_ATTR_FOUND_ROWS => true,
|
||||
PDO::MYSQL_ATTR_LOCAL_INFILE => true,
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
];
|
||||
|
||||
$std = new StdClass();
|
||||
$std->flags = $flags;
|
||||
|
||||
new PDO(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, $flags);
|
||||
var_dump($flags);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(3) {
|
||||
[1005]=>
|
||||
bool(true)
|
||||
[1001]=>
|
||||
bool(true)
|
||||
[12]=>
|
||||
bool(true)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue