[wp-trac] [WordPress Trac] #61838: Uncaught TypeError in multiple REST API endpoints from a single bug
WordPress Trac
noreply at wordpress.org
Wed Aug 7 16:27:56 UTC 2024
#61838: Uncaught TypeError in multiple REST API endpoints from a single bug
--------------------------+-----------------------------
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 requests to REST API endpoints results
in an exception multiple endpoints:
Request body:
'{"namespace": ["core/offset-text-with-a-brutalist-design-vibe", "core
/offset-text-with-a-brutalist-design-vibe"]}'
=== Command to reproduce
curl -X GET "[WORDPRESSDOMAIN]/wp-json/wp-block-editor/v1?namespace=core
/large-header-with-text-and-a-button&context=" -H 'Authorization: Basic
[ACCESS_TOKEN]' -H 'Content-Type: application/json' -d '{"namespace":
["core/offset-text-with-a-brutalist-design-vibe", "core/offset-text-with-a
-brutalist-design-vibe"]}'
curl -X PUT ["WORDPRESSDOMAIN]/wp-json/wp/v2/blocks/1" -d '{"date":
"E1VFG9QQ", "date_gmt": "447E5S8V", "slug": "", "status": "IKQHKNFP",
"password": "TX0QAG2M", "template": ["template is not one of hello-world,
blank.", "template is not one of hello-world, blank."]}' -H
'Authorization: Basic [ACCESS_TOKEN]' -H 'Content-Type: application/json'
=== Stacktrace
{{{
'<br />\n<b>Fatal error</b>: Uncaught TypeError: Illegal offset type in
isset or empty in /var/www/html/wp-includes/rest-api/endpoints/class-wp-
rest-posts-controller.php:1529\nStack trace:\n#0 /var/www/html/wp-includes
/rest-api/class-wp-rest-request.php(911):
WP_REST_Posts_Controller->check_template(Array,
Object(WP_REST_Request), \'template\')\n#1 /var/www/html/wp-includes/rest-
api/class-wp-rest-server.php(1018):
WP_REST_Request->has_valid_params()\n#2 /var/www/html/wp-includes/rest-
api/class-wp-rest-server.php(443):
WP_REST_Server->dispatch(Object(WP_REST_Request))\n#3 /var/www/html/wp-
includes/rest-api.php(410):
WP_REST_Server->serve_request(\'/wp/v2/blocks/3...\')\n#4 /var/www/html
/wp-includes/class-wp-hook.php(308): rest_api_loaded(Object(WP))\n#5
/var/www/html/wp-includes/class-wp-hook.php(332):
WP_Hook->apply_filters(\'\', Array)\n#6 /var/www/html/wp-
includes/plugin.php(565): WP_Hook->do_action(Array)\n#7 /var/www/html
/wp-includes/class-wp.php(399): do_action_ref_array(\'parse_request\',
Array)\n#8 /var/www/html/wp-includes/class-wp.php(780):
WP->parse_request(\'\')\n#9 /var/www/html/wp-
includes/functions.php(1334): WP->main(\'\')\n#10 /var/www/html/wp-
blog-header.php(16): wp()\n#11 /var/www/html/index.php(17):
require(\'/var/www/html/w...\')\n#12 {main}\n thrown in <b>/var/www/html
/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php</b> on
line <b>1529</b><br
/>\n{"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>","data":{"status":500},"additional_errors":[]}'
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61838>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list