File tree Expand file tree Collapse file tree 4 files changed +14
-7
lines changed
Expand file tree Collapse file tree 4 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,8 @@ PHP NEWS
148148 . Add enum SortDirection. (timwolla)
149149 . pathinfo() raises a ValueError with an invalid $flags argument.
150150 (David Carlier)
151+ . Passing 1 or negative base to log() now throws a ValueError.
152+ (alexandre-daubois)
151153
152154- Streams:
153155 . Added so_keepalive, tcp_keepidle, tcp_keepintvl and tcp_keepcnt stream
Original file line number Diff line number Diff line change @@ -132,6 +132,8 @@ PHP 8.6 UPGRADE NOTES
132132 constants).
133133
134134- Standard:
135+ . log() now raises a ValueError when the base argument is 1 or less
136+ than or equal to 0. Previously, base 1 silently returned NAN.
135137 . pathinfo() now raises a ValueError when an invalid $flag argument
136138 value is passed.
137139
Original file line number Diff line number Diff line change @@ -721,12 +721,8 @@ PHP_FUNCTION(log)
721721 RETURN_DOUBLE (log10 (num ));
722722 }
723723
724- if (base == 1.0 ) {
725- RETURN_DOUBLE (ZEND_NAN );
726- }
727-
728- if (base <= 0.0 ) {
729- zend_argument_value_error (2 , "must be greater than 0" );
724+ if (base <= 0.0 || base == 1.0 ) {
725+ zend_argument_value_error (2 , "must not be 1 or less than or equal to 0" );
730726 RETURN_THROWS ();
731727 }
732728
Original file line number Diff line number Diff line change 99} catch (ValueError $ exception ) {
1010 echo $ exception ->getMessage () . "\n" ;
1111}
12+
13+ try {
14+ log (36 , 1 );
15+ } catch (ValueError $ exception ) {
16+ echo $ exception ->getMessage () . "\n" ;
17+ }
1218?>
1319--EXPECT--
14- log(): Argument #2 ($base) must be greater than 0
20+ log(): Argument #2 ($base) must not be 1 or less than or equal to 0
21+ log(): Argument #2 ($base) must not be 1 or less than or equal to 0
You can’t perform that action at this time.
0 commit comments