Page MenuHomePhabricator

unexpected NAN value was coerced to string (from Language/Language.php:3543)
Closed, ResolvedPublic

Description

Cross-reference https://wiki.php.net/rfc/warnings-php-8-5#coercing_nan_to_other_types

  • mediawiki/core (47e8bf1baf66) locally, running PHP 8.5
  • composer phpunit:entrypoint -- --filter LanguageIntegrationTest
1) MediaWiki\Tests\Language\LanguageIntegrationTest::testFormatNum with data set #34 (true, 'en', NAN, false, 'Not a Number')
unexpected NAN value was coerced to string

/[...]/mediawiki/core/includes/Language/Language.php:3543
/[...]/mediawiki/core/tests/phpunit/includes/Language/LanguageIntegrationTest.php:2052

2) MediaWiki\Tests\Language\LanguageIntegrationTest::testParseFormattedNumber with data set #11 ('en', NAN)
unexpected NAN value was coerced to string

/[...]/mediawiki/core/includes/Language/Language.php:3543
/[...]/mediawiki/core/tests/phpunit/includes/Language/LanguageIntegrationTest.php:2134

(note: not yet seen in WMF experimental CI due to the order in which it runs MediaWiki's PHPUnit tests, but it presumably would be seen there at some point)

Event Timeline

Change #1225648 had a related patch set uploaded (by Akaza24; author: Akaza24):

[mediawiki/core@master] Fix NAN coercion warning in formatNum methods

https://gerrit.wikimedia.org/r/1225648

Change #1225648 merged by jenkins-bot:

[mediawiki/core@master] tests: Provide NAN as string in LanguageIntegrationTest

https://gerrit.wikimedia.org/r/1225648

Akaza24 removed Akaza24 as the assignee of this task.
Akaza24 added a project: RoadToWiki.

There is also

20:35:58 1) MediaWiki\Tests\Language\LanguageIntegrationTest::testParseFormattedNumber with data set #11 ('en', NAN)
20:35:58 unexpected NAN value was coerced to string
20:35:58 
20:35:58 /workspace/src/includes/Language/Language.php:3542
20:35:58 /workspace/src/tests/phpunit/includes/Language/LanguageIntegrationTest.php:2134

IMO it was a mistake that the previous patch just fixed the (other) test by modifying the value that the test itself was passing to Language::formatNum, rather than fixing - AFAICS - the actual compatibility issue when passing NAN to that function on PHP 8.5.

Change #1228139 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] Language: Accept NAN, INF, -INF on Language::formatNum under php8.5

https://gerrit.wikimedia.org/r/1228139

Change #1228139 abandoned by Umherirrender:

[mediawiki/core@master] Language: Accept NAN, INF, -INF on Language::formatNum under php8.5

Reason:

Going with I38f9fc1d2cecc0b25dca09351166a8f9aedf5ae2

https://gerrit.wikimedia.org/r/1228139

Change #1228173 had a related patch set uploaded (by Jforrester; author: Ammarpad):

[mediawiki/core@master] Language: Handle NAN coercion to string in formatting numbers.

https://gerrit.wikimedia.org/r/1228173

Change #1228173 merged by jenkins-bot:

[mediawiki/core@master] Language: Handle NAN coercion to string in formatting numbers.

https://gerrit.wikimedia.org/r/1228173

Change #1229785 had a related patch set uploaded (by Reedy; author: Ammarpad):

[mediawiki/core@REL1_45] Language: Handle NAN coercion to string in formatting numbers.

https://gerrit.wikimedia.org/r/1229785

Change #1229786 had a related patch set uploaded (by Reedy; author: Ammarpad):

[mediawiki/core@REL1_44] Language: Handle NAN coercion to string in formatting numbers.

https://gerrit.wikimedia.org/r/1229786

Change #1229787 had a related patch set uploaded (by Reedy; author: Ammarpad):

[mediawiki/core@REL1_43] Language: Handle NAN coercion to string in formatting numbers.

https://gerrit.wikimedia.org/r/1229787

Change #1229785 merged by jenkins-bot:

[mediawiki/core@REL1_45] Language: Handle NAN coercion to string in formatting numbers.

https://gerrit.wikimedia.org/r/1229785

Change #1229786 merged by jenkins-bot:

[mediawiki/core@REL1_44] Language: Handle NAN coercion to string in formatting numbers.

https://gerrit.wikimedia.org/r/1229786

Reedy assigned this task to Ammarpad.

Change #1229787 merged by jenkins-bot:

[mediawiki/core@REL1_43] Language: Handle NAN coercion to string in formatting numbers.

https://gerrit.wikimedia.org/r/1229787