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
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ PHP NEWS
(nielsdos)
. Fixed exit code handling of sendmail cmd and added warnings.
(Jesse Hathaway)
. Fixed bug GH-18897 (printf: empty precision is interpreted as precision 6,
not as precision 0). (nielsdos)

- Streams:
. Fixed bug GH-16889 (stream_select() timeout useless for pipes on Windows).
Expand Down
5 changes: 5 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ PHP 8.5 UPGRADE NOTES
. SplFileObject::fwrite's parameter $length is now nullable. The default
value changed from 0 to null.

- Standard:
. Using a printf-family function with a formatter that did not specify the
precision previously incorrectly reset the precision instead of treating
it as a precision of 0. See GH-18897.

========================================
2. New Features
========================================
Expand Down
1 change: 1 addition & 0 deletions ext/standard/formatted_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
expprec = 1;
} else {
precision = 0;
adjusting |= ADJ_PRECISION;
}
} else {
precision = 0;
Expand Down
10 changes: 10 additions & 0 deletions ext/standard/tests/strings/gh18897.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
GH-18897 (printf: empty precision is interpreted as precision 6, not as precision 0)
--FILE--
<?php
printf("%.f\n", 3.1415926535);
printf("%.0f\n", 3.1415926535);
?>
--EXPECT--
3
3