Make WordPress Core

Opened 8 months ago

Closed 8 months ago

#64047 closed defect (bug) (fixed)

PHP 8.5: NAN coercion warnings

Reported by: swissspidy's profile swissspidy Owned by: swissspidy's profile swissspidy
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: General Keywords: php85 has-patch has-unit-tests
Focuses: php-compatibility Cc:

Description

Parent ticket for all things PHP 8.5: #63061


These are new warnings when testing against PHP 8.5. Should probably add some is_nan() checks or remove the edge case tests.

2) Tests_Media::test_wp_convert_bytes_to_hr
The float NAN is not representable as an int, cast occurred

/var/www/src/wp-includes/deprecated.php:3374
/var/www/tests/phpunit/tests/media.php:498
/var/www/vendor/bin/phpunit:122

9) Tests_Option_WpPrimeOptionCaches::test_get_option_should_return_identical_value_when_pre_primed_by_wp_prime_option_caches with data set "NAN" (NAN)
unexpected NAN value was coerced to string

/var/www/src/wp-includes/class-wpdb.php:1763
/var/www/src/wp-includes/option.php:1143
/var/www/tests/phpunit/tests/option/wpPrimeOptionCaches.php:251
/var/www/vendor/bin/phpunit:122

Change History (2)

This ticket was mentioned in PR #10078 on WordPress/wordpress-develop by @swissspidy.


8 months ago
#1

  • Keywords has-patch has-unit-tests added; needs-patch removed

#2 @swissspidy
8 months ago

  • Owner set to swissspidy
  • Resolution set to fixed
  • Status changed from new to closed

In 60811:

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.

Note: See TracTickets for help on using tickets.