From 96f29013e0c82ef239267869250eef4b55c6519a Mon Sep 17 00:00:00 2001 From: Saki Takamachi Date: Fri, 24 Apr 2026 21:01:24 +0900 Subject: [PATCH 1/3] Fixed the behavior when using FETCH_DEFAULT (#21864) When using FETCH_DEFAULT, instead of setting the mode to a default value, it was modified so that the default value is not overridden. Closes #21864 --- NEWS | 4 ++++ ext/pdo/pdo_stmt.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 13b3286c7b67..1e917d3f01c9 100644 --- a/NEWS +++ b/NEWS @@ -76,6 +76,10 @@ PHP NEWS . Fixed bug GH-23444 (ODBC_ATTR_ASSUME_UTF8 corrupts Unicode data outside Windows). (Calvin Buckley, Lazizbek Ergashev) +- PDO Sqlite: + . Fixed bug GH-20214 (PDO::FETCH_DEFAULT unexpected behavior with + PDOStatement::setFetchMode). (SakiTakamachi) + - Phar: . Fixed bug GH-23418 (Use-after-free when looking up mounted directories). (Weilin Du) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 4e41ea40f08b..51c2f58c6c2a 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -1729,7 +1729,7 @@ 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; @@ -1737,6 +1737,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a 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: @@ -1858,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; } From e0c1b29949311be7c5a9d439567bd0aca0477d7f Mon Sep 17 00:00:00 2001 From: Saki Takamachi Date: Sat, 5 Sep 2026 10:23:24 +0900 Subject: [PATCH 2/3] NEWS for GH-21864 --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 6ca8aa09a4cd..699339680c41 100644 --- a/NEWS +++ b/NEWS @@ -68,6 +68,10 @@ PHP NEWS . Fixed PDO::CURSOR_SCROLL statements failing under lazy fetching (PDO::ATTR_PREFETCH => 0). (KentarouTakeda) +- PDO Sqlite: + . Fixed bug GH-20214 (PDO::FETCH_DEFAULT unexpected behavior with + PDOStatement::setFetchMode). (SakiTakamachi) + - Phar: . Fixed bug GH-23418 (Use-after-free when looking up mounted directories). (Weilin Du) From c54c15c25ca2cfe041c165faad5c131530476842 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Tue, 23 Jun 2026 18:39:32 +0530 Subject: [PATCH 3/3] ext/standard Fix round() for large integral doubles (#22461) Closes #22461 Closes #22411 Fixes #22410 --- NEWS | 2 ++ ext/standard/math.c | 4 ++++ ext/standard/tests/math/gh22410.phpt | 14 ++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 ext/standard/tests/math/gh22410.phpt diff --git a/NEWS b/NEWS index 1e917d3f01c9..b2e8d22465bf 100644 --- a/NEWS +++ b/NEWS @@ -100,6 +100,8 @@ PHP NEWS . Fixed a memory leak in array_merge_recursive() when the recursive merge of an object converted to an array fails. (David Carlier) . Fixed read buffer compaction in php_stream_filter_flush(). (crystarm) + . Fixed bug GH-22410 (Incorrect float behavior with large numbers). + (arshidkv12) - SimpleXML: . Fixed writing to a dimension of the object returned by attributes() not diff --git a/ext/standard/math.c b/ext/standard/math.c index 758b352f90ff..09d982981043 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -172,6 +172,10 @@ PHPAPI double _php_math_round(double value, int places, int mode) { return value; } + if (places == 0 && value == trunc(value)) { + return value; + } + places = places < INT_MIN+1 ? INT_MIN+1 : places; exponent = php_intpow10(abs(places)); diff --git a/ext/standard/tests/math/gh22410.phpt b/ext/standard/tests/math/gh22410.phpt new file mode 100644 index 000000000000..db2e92c3e6d9 --- /dev/null +++ b/ext/standard/tests/math/gh22410.phpt @@ -0,0 +1,14 @@ +--TEST-- +gh-22410: round() preserves integral doubles +--FILE-- + +--EXPECT-- +float(1) +float(-1) +float(9003241321073828) +float(-9003241321073828)