[wp-trac] [WordPress Trac] #65271: REST API Integer Type Check Fails on Large Ints
WordPress Trac
noreply at wordpress.org
Tue May 19 14:31:40 UTC 2026
#65271: REST API Integer Type Check Fails on Large Ints
--------------------------+-----------------------------
Reporter: kevinfodness | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: trunk
Severity: minor | Keywords:
Focuses: |
--------------------------+-----------------------------
The `rest_is_integer` function in `wp-includes/rest-api.php`
(https://github.com/WordPress/WordPress/blob/ae418d5505790435d008f2f8a5b24baba732fd98
/wp-includes/rest-api.php#L1572) checks whether a provided value is an
integer by running `round( (float) $maybe_integer ) === (float)
$maybe_integer` which fails on large ints. round() starts to break down on
floats on values greater than `2^52`, but the post ID field is a `BIGINT
UNSIGNED` which has a maximum value of `2^64 - 1`, so in cases where there
are very large post IDs in the database the REST API check fails (every
other number for post IDs `2^52 < x < 2^53`, every fourth number for `2^53
< x < 2^54`, and so on).
I understand that under normal usage conditions WordPress users should
never have post IDs this high (it would take billions of years of furious
publishing to hit those numbers naturally). However, I have seen an
example in the wild of where the auto increment ID was bumped to a very
high number that triggered this bug, where the IDs are still within
acceptable limits in MySQL/MariaDB and pass normal checks in PHP for
working with integers ''except'' when passing them to the REST API, which
breaks the block editor entirely (you get an error message saying the post
doesn't exist). The only fix in this situation is to renumber posts, which
is a time-consuming and error-prone endeavor, and I believe a fix in this
function would be straightforward and worth doing.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/65271>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list