[wp-trac] [WordPress Trac] #64921: REST API POST /wp/v2/posts: Undefined property stdClass::$id (line 766)
WordPress Trac
noreply at wordpress.org
Mon Mar 23 12:03:36 UTC 2026
#64921: REST API POST /wp/v2/posts: Undefined property stdClass::$id (line 766)
-------------------------------------+--------------------------
Reporter: swissspaceboy | Owner: westonruter
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 7.1
Component: General | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses: rest-api
-------------------------------------+--------------------------
Comment (by westonruter):
Oh, what's more, is that the existing logic is wrong even in the ideal
case because `$prepared_post->id` shouldn't ever exist. The valid property
is `$prepared_post->ID` because
`\WP_REST_Posts_Controller::prepare_item_for_database()` returns a
faux-`WP_Post` object, not a post object prepared for the REST API
response.
I see this was also caught by @abcd95 in https://github.com/WordPress
/wordpress-develop/pull/11327
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64921#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list