This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
Add error handling for Automattic\WooCommerceBlocks\RestApi::get_routes_from_namespace()
.
#4683
Labels
focus: rest api
Work impacting REST api routes.
type: bug
The issue/PR concerns a confirmed bug.
type: good first issue
The issue is a good candidate for the first community contribution/for a newcomer to the team.
In various places in WordPress.org forums and at least one instance in our repo (see #4647) I've noticed reports of this error show up:
The callstack for that usually points to this line:
https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/src/RestApi.php#L64
While at least one report (#4647) is triggered in the context of Elementor being used on the site, I suspect the underlying cause is that the function in question gets called before the
WP_REST_Server
is setup and/or before the namespaced being called is registered.At a minimum, we should add some
WP_Error
handling in this method and return null if it's present. This will prevent the fatal error from happening in those contexts and remove it from being a potential red herring for the real issue that may be present in this scenarios.The text was updated successfully, but these errors were encountered: