[wp-trac] [WordPress Trac] #65271: REST API Integer Type Check Fails on Large Ints
WordPress Trac
noreply at wordpress.org
Wed May 20 12:28:24 UTC 2026
#65271: REST API Integer Type Check Fails on Large Ints
----------------------------------------+-----------------------------
Reporter: kevinfodness | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: REST API | Version: 5.5
Severity: minor | Resolution:
Keywords: needs-unit-tests has-patch | Focuses:
----------------------------------------+-----------------------------
Comment (by siliconforks):
Replying to [comment:1 kevinfodness]:
> Here is an example of the bug:
>
> `> var_dump( round( (float) 9004111231758204 ) );`
> `float(9004111231758205)`
>
> I would expect the last digit to ''not'' change, but it does, because of
the lack of precision in floats of this length (16 digits) combined with
the behavior of `round`.
I think what you're seeing here is actually a bug in PHP, introduced in
PHP 8.4:
https://github.com/php/php-src/issues/18266
A quick fix might be to change `round` to `floor`, because `floor` does
not have the same weird behavior of `round`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/65271#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list