[wp-trac] [WordPress Trac] #65271: REST API Integer Type Check Fails on Large Ints
WordPress Trac
noreply at wordpress.org
Wed May 20 17:03:51 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: has-patch has-unit-tests | Focuses:
--------------------------------------+-----------------------------
Comment (by mboynes):
@siliconforks good question, and sorry I wasn't clear on that. Here's an
example of why it matters, why `floor()` doesn't solve the root issue, and
why this needs a different validation mechanism (probably something
string-based):
{{{
php > $maybe_integer = '9007199254740993.1';
php > var_dump(floor( (float) $maybe_integer ) === (float)
$maybe_integer);
bool(true)
}}}
In fact, this problem surfaces at 2^50^ if we're including decimals, since
the double needs bits to represent the decimal...
{{{
php > $maybe_integer = 2**49 + 0.1;
php > var_dump(floor( (float) $maybe_integer ) === (float)
$maybe_integer);
bool(false)
php > $maybe_integer = 2**50 + 0.1;
php > var_dump(floor( (float) $maybe_integer ) === (float)
$maybe_integer);
bool(true)
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/65271#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list