mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-5.6'
Conflicts: ext/pdo/pdo_dbh.c ext/pdo/php_pdo_driver.h
This commit is contained in:
commit
014abbc840
5 changed files with 69 additions and 31 deletions
3
NEWS
3
NEWS
|
@ -24,6 +24,9 @@ PHP NEWS
|
|||
. Fixed bug #70386 (Can't compile on NetBSD because of missing WCONTINUED
|
||||
and WIFCONTINUED). (Matteo)
|
||||
|
||||
- PDO:
|
||||
- Fixed bug #70389 (PDO constructor changes unrelated variables). (Laruence)
|
||||
|
||||
- PDO_OCI:
|
||||
. Fixed bug #70308 (PDO::ATTR_PREFETCH is ignored). (Chris Jones)
|
||||
|
||||
|
|
|
@ -281,8 +281,7 @@ static PHP_METHOD(PDO, dbh_constructor)
|
|||
Z_STRVAL_P(v));
|
||||
is_persistent = 1;
|
||||
} else {
|
||||
convert_to_long_ex(v);
|
||||
is_persistent = Z_LVAL_P(v) ? 1 : 0;
|
||||
is_persistent = zval_get_long(v) ? 1 : 0;
|
||||
plen = spprintf(&hashkey, 0, "PDO:DBH:DSN=%s:%s:%s", data_source,
|
||||
username ? username : "",
|
||||
password ? password : "");
|
||||
|
|
|
@ -199,20 +199,18 @@ static inline zend_long pdo_attr_lval(zval *options, enum pdo_attribute_type opt
|
|||
zval *v;
|
||||
|
||||
if (options && (v = zend_hash_index_find(Z_ARRVAL_P(options), option_name))) {
|
||||
convert_to_long_ex(v);
|
||||
return Z_LVAL_P(v);
|
||||
return zval_get_long(v);
|
||||
}
|
||||
return defval;
|
||||
}
|
||||
static inline char *pdo_attr_strval(zval *options, enum pdo_attribute_type option_name, char *defval)
|
||||
static inline zend_string *pdo_attr_strval(zval *options, enum pdo_attribute_type option_name, zend_string *defval)
|
||||
{
|
||||
zval *v;
|
||||
|
||||
if (options && (v = zend_hash_index_find(Z_ARRVAL_P(options), option_name))) {
|
||||
convert_to_string_ex(v);
|
||||
return estrndup(Z_STRVAL_P(v), Z_STRLEN_P(v));
|
||||
return zval_get_string(v);
|
||||
}
|
||||
return defval ? estrdup(defval) : NULL;
|
||||
return defval ? zend_string_copy(defval) : NULL;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -602,12 +602,12 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
|
|||
if (driver_options) {
|
||||
zend_long connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30);
|
||||
zend_long local_infile = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0);
|
||||
char *init_cmd = NULL;
|
||||
zend_string *init_cmd = NULL;
|
||||
#ifndef PDO_USE_MYSQLND
|
||||
char *default_file = NULL, *default_group = NULL;
|
||||
zend_string *default_file = NULL, *default_group = NULL;
|
||||
#endif
|
||||
zend_long compress = 0;
|
||||
char *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL, *ssl_cipher = NULL;
|
||||
zend_string *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL, *ssl_cipher = NULL;
|
||||
H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1);
|
||||
|
||||
H->emulate_prepare = pdo_attr_lval(driver_options,
|
||||
|
@ -658,32 +658,32 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
|
|||
#endif
|
||||
init_cmd = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_INIT_COMMAND, NULL);
|
||||
if (init_cmd) {
|
||||
if (mysql_options(H->server, MYSQL_INIT_COMMAND, (const char *)init_cmd)) {
|
||||
efree(init_cmd);
|
||||
if (mysql_options(H->server, MYSQL_INIT_COMMAND, (const char *)ZSTR_VAL(init_cmd))) {
|
||||
zend_string_release(init_cmd);
|
||||
pdo_mysql_error(dbh);
|
||||
goto cleanup;
|
||||
}
|
||||
efree(init_cmd);
|
||||
zend_string_release(init_cmd);
|
||||
}
|
||||
#ifndef PDO_USE_MYSQLND
|
||||
default_file = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_FILE, NULL);
|
||||
if (default_file) {
|
||||
if (mysql_options(H->server, MYSQL_READ_DEFAULT_FILE, (const char *)default_file)) {
|
||||
efree(default_file);
|
||||
if (mysql_options(H->server, MYSQL_READ_DEFAULT_FILE, (const char *)ZSTR_VAL(default_file))) {
|
||||
zend_string_release(default_file);
|
||||
pdo_mysql_error(dbh);
|
||||
goto cleanup;
|
||||
}
|
||||
efree(default_file);
|
||||
zend_string_release(default_file);
|
||||
}
|
||||
|
||||
default_group= pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_GROUP, NULL);
|
||||
default_group = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_GROUP, NULL);
|
||||
if (default_group) {
|
||||
if (mysql_options(H->server, MYSQL_READ_DEFAULT_GROUP, (const char *)default_group)) {
|
||||
efree(default_group);
|
||||
if (mysql_options(H->server, MYSQL_READ_DEFAULT_GROUP, (const char *)ZSTR_VAL(default_group))) {
|
||||
zend_string_release(default_group);
|
||||
pdo_mysql_error(dbh);
|
||||
goto cleanup;
|
||||
}
|
||||
efree(default_group);
|
||||
zend_string_release(default_group);
|
||||
}
|
||||
#endif
|
||||
compress = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_COMPRESS, 0);
|
||||
|
@ -701,34 +701,39 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
|
|||
ssl_cipher = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_CIPHER, NULL);
|
||||
|
||||
if (ssl_key || ssl_cert || ssl_ca || ssl_capath || ssl_cipher) {
|
||||
mysql_ssl_set(H->server, ssl_key, ssl_cert, ssl_ca, ssl_capath, ssl_cipher);
|
||||
mysql_ssl_set(H->server,
|
||||
ssl_key? ZSTR_VAL(ssl_key) : NULL,
|
||||
ssl_cert? ZSTR_VAL(ssl_cert) : NULL,
|
||||
ssl_ca? ZSTR_VAL(ssl_ca) : NULL,
|
||||
ssl_capath? ZSTR_VAL(ssl_capath) : NULL,
|
||||
ssl_cipher? ZSTR_VAL(ssl_cipher) : NULL);
|
||||
if (ssl_key) {
|
||||
efree(ssl_key);
|
||||
zend_string_release(ssl_key);
|
||||
}
|
||||
if (ssl_cert) {
|
||||
efree(ssl_cert);
|
||||
zend_string_release(ssl_cert);
|
||||
}
|
||||
if (ssl_ca) {
|
||||
efree(ssl_ca);
|
||||
zend_string_release(ssl_ca);
|
||||
}
|
||||
if (ssl_capath) {
|
||||
efree(ssl_capath);
|
||||
zend_string_release(ssl_capath);
|
||||
}
|
||||
if (ssl_cipher) {
|
||||
efree(ssl_cipher);
|
||||
zend_string_release(ssl_cipher);
|
||||
}
|
||||
}
|
||||
|
||||
#if MYSQL_VERSION_ID > 50605 || defined(PDO_USE_MYSQLND)
|
||||
{
|
||||
char *public_key = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY, NULL);
|
||||
zend_string *public_key = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY, NULL);
|
||||
if (public_key) {
|
||||
if (mysql_options(H->server, MYSQL_SERVER_PUBLIC_KEY, public_key)) {
|
||||
if (mysql_options(H->server, MYSQL_SERVER_PUBLIC_KEY, ZSTR_VAL(public_key))) {
|
||||
pdo_mysql_error(dbh);
|
||||
efree(public_key);
|
||||
zend_string_release(public_key);
|
||||
goto cleanup;
|
||||
}
|
||||
efree(public_key);
|
||||
zend_string_release(public_key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
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