diff options
author | Matteo Beccati <mbeccati@php.net> | 2015-01-05 10:48:40 +0100 |
---|---|---|
committer | Matteo Beccati <mbeccati@php.net> | 2015-01-05 10:48:40 +0100 |
commit | 7d0887a229a28c465781d6e4a00c6df61112bcd5 (patch) | |
tree | b9b673f96fae9190229cf6d45bc7667e29f314db /ext/pdo_mysql | |
parent | c234ca8e17a844225a3ce5c64df9fdc5f39e23b9 (diff) | |
parent | 488d3dac2e7d77223efb3bd4748e14e5b6be0156 (diff) | |
download | php-git-7d0887a229a28c465781d6e4a00c6df61112bcd5.tar.gz |
Merge branch 'PHP-5.6'
* PHP-5.6:
Fixed bug #68371 PDO#getAttribute() cannot be called with platform-specific attribute names
Diffstat (limited to 'ext/pdo_mysql')
-rw-r--r-- | ext/pdo_mysql/mysql_driver.c | 1 | ||||
-rw-r--r-- | ext/pdo_mysql/tests/bug68371.phpt | 101 |
2 files changed, 102 insertions, 0 deletions
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index 66b70949cb..4f75f02cf1 100644 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -463,6 +463,7 @@ static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_ ZVAL_LONG(return_value, H->buffered); break; + case PDO_ATTR_EMULATE_PREPARES: case PDO_MYSQL_ATTR_DIRECT_QUERY: ZVAL_LONG(return_value, H->emulate_prepare); break; diff --git a/ext/pdo_mysql/tests/bug68371.phpt b/ext/pdo_mysql/tests/bug68371.phpt new file mode 100644 index 0000000000..cac93c9668 --- /dev/null +++ b/ext/pdo_mysql/tests/bug68371.phpt @@ -0,0 +1,101 @@ +--TEST-- +PDO MySQL Bug #38671 (PDO#getAttribute() cannot be called with platform-specific attribute names) +--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_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); +$pdo = MySQLPDOTest::factory(); +$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + +$attrs = array( + // Extensive test: default value and set+get values + PDO::ATTR_EMULATE_PREPARES => array(null, 1, 0), + PDO::MYSQL_ATTR_DIRECT_QUERY => array(null, 0, 1), + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => array(null, 0, 1), + + // Just test the default + PDO::ATTR_AUTOCOMMIT => array(null), + PDO::ATTR_PREFETCH => array(null), + PDO::ATTR_TIMEOUT => array(null), + PDO::ATTR_ERRMODE => array(null), + PDO::ATTR_SERVER_VERSION => array(null), + PDO::ATTR_CLIENT_VERSION => array(null), + PDO::ATTR_SERVER_INFO => array(null), + PDO::ATTR_CONNECTION_STATUS => array(null), + PDO::ATTR_CASE => array(null), + PDO::ATTR_CURSOR_NAME => array(null), + PDO::ATTR_CURSOR => array(null), + PDO::ATTR_ORACLE_NULLS => array(null), + PDO::ATTR_PERSISTENT => array(null), + PDO::ATTR_STATEMENT_CLASS => array(null), + PDO::ATTR_FETCH_TABLE_NAMES => array(null), + PDO::ATTR_FETCH_CATALOG_NAMES => array(null), + PDO::ATTR_DRIVER_NAME => array(null), + PDO::ATTR_STRINGIFY_FETCHES => array(null), + PDO::ATTR_MAX_COLUMN_LEN => array(null), + PDO::ATTR_DEFAULT_FETCH_MODE => array(null), +); + +foreach ($attrs as $a => $vals) { + foreach ($vals as $v) { + try { + if (!isset($v)) { + var_dump($pdo->getAttribute($a)); + } else { + $pdo->setAttribute($a, $v); + if ($pdo->getAttribute($a) === $v) { + echo "OK\n"; + } else { + throw new \Exception('KO'); + } + } + } catch (\Exception $e) { + if ($e->getCode() == 'IM001') { + echo "ERR\n"; + } else { + echo "ERR {$e->getMessage()}\n"; + } + } + } +} + +?> +--EXPECTF-- +int(1) +OK +OK +int(0) +OK +OK +int(1) +OK +OK +int(1) +ERR +ERR +int(2) +string(%d) "%s" +string(%d) "%s" +string(%d) "%s" +string(%d) "%s" +int(2) +ERR +ERR +int(0) +bool(false) +array(1) { + [0]=> + string(12) "PDOStatement" +} +ERR +ERR +string(5) "mysql" +ERR +ERR +int(4) + |