Skip to content

Commit c6cfbe9

Browse files
committed
Code Modernization: Avoid NAN coercion/cast deprecation warnings.
Coercing `INF` or `NAN` to a string or casting to int is deprecated in PHP 8.5+. This change addresses two occurrences in core where this was happening. Props swissspidy. Fixes #64047. See #63061. git-svn-id: https://develop.svn.wordpress.org/trunk@60811 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6db003c commit c6cfbe9

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

src/wp-includes/deprecated.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3371,7 +3371,7 @@ function wp_convert_bytes_to_hr( $bytes ) {
33713371

33723372
$units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' );
33733373
$log = log( $bytes, KB_IN_BYTES );
3374-
$power = (int) $log;
3374+
$power = ! is_nan( $log ) && ! is_infinite( $log ) ? (int) $log : 0;
33753375
$size = KB_IN_BYTES ** ( $log - $power );
33763376

33773377
if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) {

tests/phpunit/tests/option/wpPrimeOptionCaches.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ public function data_option_types() {
455455
'empty object' => array( new stdClass() ),
456456
'populated object' => array( (object) array( 'string' ) ),
457457
'INF' => array( INF ),
458-
'NAN' => array( NAN ),
459458
);
460459
}
461460
}

0 commit comments

Comments
 (0)