[wp-trac] [WordPress Trac] #61837: Uncaught TypeError in wp/v2/posts/{id} endpoint
WordPress Trac
noreply at wordpress.org
Wed Aug 7 16:22:00 UTC 2024
#61837: Uncaught TypeError in wp/v2/posts/{id} endpoint
--------------------------+-----------------------------
Reporter: mlf20 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 6.2.2
Severity: normal | Keywords:
Focuses: rest-api |
--------------------------+-----------------------------
Upon creating a fresh instance of WordPress and setting up the REST API a
malformed post request REST API endpoint /wp-json/wp/v2/posts/{id} results
in an exception in the endpoint.
Request body:
'{"date": "2024-08-07T02:04:37", "date_gmt": "2024-08-07T02:04:37",
"slug": "hello-world", "status": "publish", "password": 99999999,
"author": 1, "featured_media": 0, "comment_status": "open", "ping_status":
"open", "format": "", "sticky": false, "template": "PE9PCU5W",
"categories": [], "tags": [""]}'
=== Command to reproduce
curl -X POST "[WORDPRESSDOMAIN]/wp-json/wp/v2/posts/1" --data '{"date":
"2024-08-07T02:04:37", "date_gmt": "2024-08-07T02:04:37", "slug": "hello-
world", "status": "publish", "password": 99999999, "author": 1,
"featured_media": 0, "comment_status": "open", "ping_status": "open",
"format": "", "sticky": false, "template": "PE9PCU5W", "categories": [],
"tags": [""]}' -H 'Authorization: Basic [ACCESS_TOKEN]' -H 'Content-Type:
application/json'
=== Stacktrace
{{{
<br />
<b>Fatal error</b>: Uncaught TypeError: hash_equals(): Argument #2
($user_string) must be of type string, int given in /var/www/html/wp-
includes/rest-api/endpoints/class-wp-rest-posts-controller.php:496
Stack trace:
#0 /var/www/html/wp-includes/rest-api/endpoints/class-wp-rest-posts-
controller.php(496): hash_equals('', 99999999)
#1 /var/www/html/wp-includes/rest-api.php(821):
WP_REST_Posts_Controller->get_item_permissions_check(Object(WP_REST_Request))
#2 /var/www/html/wp-includes/class-wp-hook.php(308):
rest_send_allow_header(Object(WP_REST_Response), Object(WP_REST_Server),
Object(WP_REST_Request))
#3 /var/www/html/wp-includes/plugin.php(205):
WP_Hook->apply_filters(Object(WP_REST_Response), Array)
#4 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(466):
apply_filters('rest_post_dispa...', Object(WP_REST_Response),
Object(WP_REST_Server), Object(WP_REST_Request))
#5 /var/www/html/wp-includes/rest-api.php(410):
WP_REST_Server->serve_request('/wp/v2/posts/1')
#6 /var/www/html/wp-includes/class-wp-hook.php(308):
rest_api_loaded(Object(WP))
#7 /var/www/html/wp-includes/class-wp-hook.php(332):
WP_Hook->apply_filters('', Array)
#8 /var/www/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#9 /var/www/html/wp-includes/class-wp.php(399):
do_action_ref_array('parse_request', Array)
#10 /var/www/html/wp-includes/class-wp.php(780): WP->parse_request('')
#11 /var/www/html/wp-includes/functions.php(1334): WP->main('')
#12 /var/www/html/wp-blog-header.php(16): wp()
#13 /var/www/html/index.php(17): require('/var/www/html/w...')
#14 {main}
thrown in <b>/var/www/html/wp-includes/rest-api/endpoints/class-wp-rest-
posts-controller.php</b> on line <b>496</b><br />
{"code":"internal_server_error","message":"<p>There has been a critical
error on this website.<\/p><p><a
href=\"https:\/\/wordpress.org\/documentation\/article\/faq-
troubleshooting\/\">Learn more about troubleshooting WordPress.<\/a><\/p>
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61837>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list