[php-src] master: Merge branch 'PHP-8.6'
| From: | Ilia Alshanetsky | Date: | Wed, 14 Oct 2026 13:41:05 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142268@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-10-14T09:34:06-04:00
Commit: https://github.com/php/php-src/commit/41ea9d310d2d2a41dc2f4471faffcc2a71692581
Raw diff: https://github.com/php/php-src/commit/41ea9d310d2d2a41dc2f4471faffcc2a71692581.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
ext/pdo: Report $options as the argument for constructor option errors
Changed paths:
A ext/pdo/tests/pdo_constructor_option_argnum.phpt
M ext/pdo/pdo_dbh.c
Diff:
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index 2277df62a37b..52d5639aa499 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -509,7 +509,7 @@ PDO_API void php_pdo_internal_construct_driver(INTERNAL_FUNCTION_PARAMETERS, zen
ZVAL_DEREF(attr_value);
/* TODO: Should the constructor fail when the attribute cannot be set? */
- pdo_dbh_attribute_set(dbh, long_key, attr_value, 3);
+ pdo_dbh_attribute_set(dbh, long_key, attr_value, 4);
} ZEND_HASH_FOREACH_END();
}
diff --git a/ext/pdo/tests/pdo_constructor_option_argnum.phpt
b/ext/pdo/tests/pdo_constructor_option_argnum.phpt
new file mode 100644
index 000000000000..5aebe0b4a2a5
--- /dev/null
+++ b/ext/pdo/tests/pdo_constructor_option_argnum.phpt
@@ -0,0 +1,38 @@
+--TEST--
+PDO Common: Constructor option errors report $options as argument #4
+--EXTENSIONS--
+pdo
+--SKIPIF--
+<?php
+$dir = getenv('REDIR_TEST_DIR');
+if (false == $dir) die('skip no driver');
+require_once $dir . 'pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ .
'/../../pdo/tests/');
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+
+foreach ([false, true] as $useConnectMethod) {
+ foreach ([[PDO::ATTR_ERRMODE => 999], [PDO::ATTR_STATEMENT_CLASS =>
'PDOStatement']] as $options) {
+ putenv("PDOTEST_ATTR=" . serialize($options));
+ try {
+ PDOTest::factory(PDO::class, $useConnectMethod);
+ } catch (Error $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+ }
+ }
+
+ putenv("PDOTEST_ATTR=" . serialize([PDO::ATTR_DEFAULT_FETCH_MODE =>
PDO::FETCH_NUM]));
+ $db = PDOTest::factory(PDO::class, $useConnectMethod);
+ var_dump($db->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE) === PDO::FETCH_NUM);
+}
+?>
+--EXPECT--
+ValueError: PDO::__construct(): Argument #4 ($options) Error mode must be one of the PDO::ERRMODE_*
constants
+TypeError: PDO::__construct(): Argument #4 ($options) PDO::ATTR_STATEMENT_CLASS value must be of
type array, string given
+bool(true)
+ValueError: PDO::connect(): Argument #4 ($options) Error mode must be one of the PDO::ERRMODE_*
constants
+TypeError: PDO::connect(): Argument #4 ($options) PDO::ATTR_STATEMENT_CLASS value must be of type
array, string given
+bool(true)