Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 798 forks source link

Strict type checks lead to fatal errors on null argument. #36360

Open zinigor opened 8 months ago

zinigor commented 8 months ago

Impacted plugin

Jetpack

Quick summary

Some WoA sites are affected by this problem because apparently they have submenus with not well-defined properties. Here's the error stack trace:

PHP Fatal error:  Uncaught TypeError: WPCOM_REST_API_V2_Endpoint_Admin_Menu::prepare_submenu_item(): Argument #1 ($submenu_item) must be of type array, null given, called in /wordpress/plugins/jetpack/13.2-beta/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php on line 149 and defined in /wordpress/plugins/jetpack/13.2-beta/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php:314
Stack trace:
#0 /wordpress/plugins/jetpack/13.2-beta/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php(149): WPCOM_REST_API_V2_Endpoint_Admin_Menu->prepare_submenu_item(NULL, Array)
#1 /wordpress/plugins/jetpack/13.2-beta/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php(95): WPCOM_REST_API_V2_Endpoint_Admin_Menu->prepare_menu_for_response(Array)
#2 /wordpress/core/6.4.3/wp-includes/rest-api/class-wp-rest-server.php(1193): WPCOM_REST_API_V2_Endpoint_Admin_Menu->get_item(Object(WP_REST_Request))
#3 /wordpress/core/6.4.3/wp-includes/rest-api/class-wp-rest-server.php(1041): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wpcom/v2/admin...', Array, NULL)
#4 /wordpress/core/6.4.3/wp-includes/rest-api/class-wp-rest-server.php(431): WP_REST_Server->dispatch(Object(WP_REST_Request))
#5 /wordpress/core/6.4.3/wp-includes/rest-api.php(424): WP_REST_Server->serve_request('/wpcom/v2/admin...')
#6 /wordpress/core/6.4.3/wp-includes/class-wp-hook.php(324): rest_api_loaded(Object(WP))
#7 /wordpress/core/6.4.3/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#8 /wordpress/core/6.4.3/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#9 /wordpress/core/6.4.3/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)
#10 /wordpress/core/6.4.3/wp-includes/class-wp.php(813): WP->parse_request('')
#11 /wordpress/core/6.4.3/wp-includes/functions.php(1336): WP->main('')
#12 /wordpress/core/6.4.3/wp-blog-header.php(16): wp()
#13 /wordpress/core/6.4.3/index.php(17): require('/wordpress/core...')
#14 {main}
  thrown in /wordpress/plugins/jetpack/13.2-beta/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-admin-menu.php on line 314

Steps to reproduce

I don't have clear reproduction steps yet because it seems to be caused by a plugin/theme combination.

A clear and concise description of what you expected to happen.

No response

What actually happened

No response

Impact

Some (< 50%)

Available workarounds?

No and the platform is unusable

Platform (Simple and/or Atomic)

Atomic, Self-hosted

Logs or notes

No response

github-actions[bot] commented 2 months ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.