From c5a2b407d71c6df729523ebe19099df0d37cdc4f Mon Sep 17 00:00:00 2001 From: Saki Takamachi Date: Fri, 24 Apr 2026 21:01:24 +0900 Subject: [PATCH] When using `FETCH_DEFAULT`, instead of setting the mode to a default value, it was modified so that the default value is not overridden. --- ext/pdo/pdo_stmt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 2ae3b1dd9e8c..da80e04547a2 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -1729,18 +1729,16 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a ; } - stmt->default_fetch_type = PDO_FETCH_BOTH; + stmt->default_fetch_type = stmt->dbh->default_fetch_type; flags = mode & PDO_FETCH_FLAGS; - if ((mode & ~PDO_FETCH_FLAGS) == PDO_FETCH_USE_DEFAULT) { - mode = stmt->dbh->default_fetch_type | flags; - } - if (!pdo_stmt_verify_mode(stmt, mode, mode_arg_num, false)) { return false; } + bool use_default = (mode & ~PDO_FETCH_FLAGS) == PDO_FETCH_USE_DEFAULT; + switch (mode & ~PDO_FETCH_FLAGS) { case PDO_FETCH_USE_DEFAULT: case PDO_FETCH_LAZY: @@ -1862,7 +1860,9 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a return false; } - stmt->default_fetch_type = mode; + if (!use_default) { + stmt->default_fetch_type = mode; + } return true; }