Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1624,14 +1624,16 @@ 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;

if (!pdo_verify_fetch_mode(stmt->default_fetch_type, 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:
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions ext/standard/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
14 changes: 14 additions & 0 deletions ext/standard/tests/math/gh22410.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
gh-22410: round() preserves integral doubles
--FILE--
<?php
var_dump(round(1.0));
var_dump(round(-1.0));
var_dump(round((float) 9003241321073828));
var_dump(round((float) -9003241321073828));
?>
--EXPECT--
float(1)
float(-1)
float(9003241321073828)
float(-9003241321073828)