Open Ninodevo opened 1 year ago
Hey @jeherve, I'm wondering if you can share any insight for this issue being looked at?
@xpurichan I don't believe anyone is looking into this issue at the moment.
@davemart-in Do you think that's something you could look at as part of the Untangling Calypso project?
Yup! @jeherve I just moved it to our board. Thanks for the ping!
Removing this from the logical flows board. It's no longer a great fit.
Impacted plugin
Jetpack
Steps to Reproduce
The used plugin here is only an example that causes the issue it could also be other plugins with similar implementations.
Example 1:
https://public-api.wordpress.com/wpcom/v2/sites/{blog_id}/admin-menu
(Authorization: Bearer {token})Example 2:
A clear and concise description of what you expected to happen.
Example 1: I expect to get response 200 and an admin menu item.
Example 2: I expect to not see any fatal errors related to the MetaSlider plugin.
What actually happened
Example 1:
I received error 500:
Example 2:
I see a fatal error:
PHP Fatal error: Uncaught Error: Call to a member function add_page() on null...
2e365-pbBrowser
Google Chrome/Chromium
Other information
I believe that the issue is not in the plugin but in how our Jetpack WPCOM endpoint
wpcom/v2/admin-menu
is implemented -> wpcom-rest-api-v2-endpoint-admin-menu.phpHere is the code 2e366-pb from the MetaSlider plugin (how the plugin is written is not important only the code I will highlight). On line 116
is_admin()
check is used to init a class property and on line 282add_action('admin_menu', array($this, 'register_admin_pages'), 9553);
a hook is added toadmin_menu
whose callback uses the initialized class property inis_admin
. The hookadmin_menu
is only called in the admin so that should be ok.In the Jetpack WPCOM endpoint
wpcom/v2/admin-menu
theget_item
function includes thewp-admin/menu
file on line 91 which subsequently includes thewp-admin/includes/menu.php
file and that triggers theadmin_menu
hook butis_admin
returns false.The endpoint
wpcom/v2/admin-menu
-> triggersadmin_menu
hook butis_admin
is false which shouldn't happenI believe
is_admin
should be true if we are using thewpcom/v2/admin-menu
endpoint or the implementation of the route should be in some other way (not including the WP admin files).The plugin author should be able to use the
is_admin
function in regard to theadmin_menu
hook (which should only be fired in the admin). This plugin is only an example if there are similar implementations of usingis_admin
in combination of the admin menu hooks those will fail.Platform (Simple, Atomic, or both?)
Atomic
Reproducibility
Consistent
Severity
Some (< 50%)
Available workarounds?
No response
Workaround details
No response