diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index a414dcb62dd0..d458bb94ec90 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -1624,7 +1624,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a pdo_stmt_free_default_fetch_mode(stmt); - stmt->default_fetch_type = PDO_FETCH_BOTH; + stmt->default_fetch_type = stmt->dbh->default_fetch_type; flags = mode & PDO_FETCH_FLAGS; @@ -1632,6 +1632,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: @@ -1747,7 +1749,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; } diff --git a/ext/standard/math.c b/ext/standard/math.c index e13f153f63e2..20286870c7c9 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -170,6 +170,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)