com php-src: Fixed bug #70389 (PDO constructor changes unrelated variables): NEWS ext/pdo/pdo_dbh.c ext/pdo/php_pdo_dr iver.h
ext/pdo_mysql/tests/bug70389.phpt

From: Date: Sun, 30 Aug 2015 12:02:38 +0000
Subject: com php-src: Fixed bug #70389 (PDO constructor changes unrelated variables): NEWS ext/pdo/pdo_dbh.c ext/pdo/php_pdo_dr iver.h
ext/pdo_mysql/tests/bug70389.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-88803@lists.php.net to get a copy of this message
Commit: ef1bd8f0e6f88b1d123cea1c0b5079cfde7f90df Author: Xinchen Hui <laruence@gmail.com> Sun, 30 Aug 2015 05:02:13 -0700 Parents: 00eebd7a477f8076a5fbb4712f380c8214952bdf Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ef1bd8f0e6f88b1d123cea1c0b5079cfde7f90df Log: Fixed bug #70389 (PDO constructor changes unrelated variables) Bugs: https://bugs.php.net/70389 Changed paths: M NEWS M ext/pdo/pdo_dbh.c M ext/pdo/php_pdo_driver.h A ext/pdo_mysql/tests/bug70389.phpt Diff: diff --git a/NEWS b/NEWS index 85b83b9..8f68c45 100644 --- a/NEWS +++ b/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) diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 6857a9b..c7d7e07 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -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 : ""); diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h index d651345..44082df 100644 --- a/ext/pdo/php_pdo_driver.h +++ b/ext/pdo/php_pdo_driver.h @@ -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; diff --git a/ext/pdo_mysql/tests/bug70389.phpt b/ext/pdo_mysql/tests/bug70389.phpt new file mode 100644 index 0000000..b9084f6 --- /dev/null +++ b/ext/pdo_mysql/tests/bug70389.phpt @@ -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) +}

« previous php.cvs (#88803) next »