summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UPGRADING6
-rw-r--r--ext/pdo/pdo_dbh.c5
-rw-r--r--ext/pdo/pdo_dbh.stub.php2
-rw-r--r--ext/pdo/pdo_dbh_arginfo.h4
-rw-r--r--ext/pdo/tests/bug_44173.phpt2
5 files changed, 11 insertions, 8 deletions
diff --git a/UPGRADING b/UPGRADING
index bf4584bb8e..a98aeab045 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -350,9 +350,11 @@ PHP 8.0 UPGRADE NOTES
"exceptions". See https://www.php.net/manual/en/pdo.error-handling.php
for details of behavior changes and how to explicitly set this attribute.
RFC: https://wiki.php.net/rfc/pdo_default_errmode
- . The method PDOStatement::setFetchMode() now accepts the following signature:
+ . The signatures of some PDO methods have changed:
- PDOStatement::setFetchMode($mode, $classname, $params)
+ PDO::query(
+ string $statement, ?int $fetch_mode = null, ...$fetch_mode_args)
+ PDOStatement::setFetchMode(int $mode, ...$params)
- PDO_ODBC:
. The php.ini directive pdo_odbc.db2_instance_name has been removed
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index 330a7532c5..583374240c 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -1026,12 +1026,13 @@ PHP_METHOD(PDO, query)
char *statement;
size_t statement_len;
zend_long fetch_mode;
+ zend_bool fetch_mode_is_null = 1;
zval *args = NULL;
uint32_t num_args = 0;
pdo_dbh_object_t *dbh_obj = Z_PDO_OBJECT_P(ZEND_THIS);
pdo_dbh_t *dbh = dbh_obj->inner;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|l*", &statement, &statement_len, &fetch_mode, &args, &num_args)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|l!*", &statement, &statement_len, &fetch_mode, &fetch_mode_is_null, &args, &num_args)) {
RETURN_THROWS();
}
@@ -1061,7 +1062,7 @@ PHP_METHOD(PDO, query)
if (dbh->methods->preparer(dbh, statement, statement_len, stmt, NULL)) {
PDO_STMT_CLEAR_ERR();
- if (ZEND_NUM_ARGS() == 1 || SUCCESS == pdo_stmt_setup_fetch_mode(stmt, fetch_mode, args, num_args)) {
+ if (fetch_mode_is_null || SUCCESS == pdo_stmt_setup_fetch_mode(stmt, fetch_mode, args, num_args)) {
/* now execute the statement */
PDO_STMT_CLEAR_ERR();
diff --git a/ext/pdo/pdo_dbh.stub.php b/ext/pdo/pdo_dbh.stub.php
index 2fe9572344..bde46dd712 100644
--- a/ext/pdo/pdo_dbh.stub.php
+++ b/ext/pdo/pdo_dbh.stub.php
@@ -37,7 +37,7 @@ class PDO
public function prepare(string $statement, array $driver_options = []) {}
/** @return PDOStatement|false */
- public function query(string $statement, int $fetch_mode = UNKNOWN, ...$fetch_mode_args) {}
+ public function query(string $statement, ?int $fetch_mode = null, ...$fetch_mode_args) {}
/** @return string|false */
public function quote(string $string, int $parameter_type = PDO::PARAM_STR) {}
diff --git a/ext/pdo/pdo_dbh_arginfo.h b/ext/pdo/pdo_dbh_arginfo.h
index 5962544c02..1057c54665 100644
--- a/ext/pdo/pdo_dbh_arginfo.h
+++ b/ext/pdo/pdo_dbh_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: c329bfda55244467a2cd62f9d5c5120ec3f24eef */
+ * Stub hash: 36270d1418fc4ddd8f79018372b0ef00fb6f5889 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, dsn, IS_STRING, 0)
@@ -40,7 +40,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_query, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, statement, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO(0, fetch_mode, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fetch_mode, IS_LONG, 1, "null")
ZEND_ARG_VARIADIC_INFO(0, fetch_mode_args)
ZEND_END_ARG_INFO()
diff --git a/ext/pdo/tests/bug_44173.phpt b/ext/pdo/tests/bug_44173.phpt
index 1c1d14068c..df98f332fe 100644
--- a/ext/pdo/tests/bug_44173.phpt
+++ b/ext/pdo/tests/bug_44173.phpt
@@ -54,7 +54,7 @@ var_dump($stmt);
--EXPECTF--
Warning: PDO::query(): SQLSTATE[HY000]: General error: fetch mode doesn't allow any extra arguments in %s
bool(false)
-PDO::query(): Argument #2 ($fetch_mode) must be of type int, string given
+PDO::query(): Argument #2 ($fetch_mode) must be of type ?int, string given
Warning: PDO::query(): SQLSTATE[HY000]: General error: too many arguments in %s
bool(false)