Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPcom_Admin_Menu: Add special cases that don't have menus extended #22804

Closed
wants to merge 7 commits into from

Conversation

mreishus
Copy link
Contributor

@mreishus mreishus commented Feb 10, 2022

Changes proposed in this Pull Request:

For more background info, see p55Cj4-1xc-p2

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Visit /wp-admin?service-worker. Before and after the patch, the data returned should be exactly the same.
    • BEFORE: On WPCOM, /wp-admin?service-worker will cause get_top_messages() in jitm-engine.php to run, however, the data will not be used, as there is nowhere to display the messages.
    • AFTER: /wp-admin?service-worker will not cause get_top_messages() in jitm-engine.php to run
  • Same with /wp-admin/index-yourstuff.php and /wp-admin/index-hotstuff.php

Logging screenshots before/after

Loading /wp-admin/ on my simple site before changes (JITM rendered 5 times)
2022-02-11_15-53-before

Loading /wp-admin/ on my simple site after changes (JITM rendered once)
2022-02-11_15-53-after

@mreishus mreishus self-assigned this Feb 10, 2022
@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Feature] Masterbar WordPress.com Toolbar and Dashboard customizations labels Feb 10, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ⚠️ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: March 1, 2022.
  • Scheduled code freeze: February 22, 2022.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Feb 10, 2022
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello mreishus! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D74790-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@mreishus
Copy link
Contributor Author

mreishus commented Feb 10, 2022

Less than ideal: I'm now able to visit /wp-admin/themes.php?service-worker on my simple site, and see the themes page with non-enhanced menus.

The new method used prevents this, as it only checks for ?service-worker on index.php.

@mreishus mreishus force-pushed the change/service-worker-admin-menu-action branch from ef6c86a to f80c28f Compare February 11, 2022 21:35
@mreishus mreishus changed the title Base_Admin_Menu: Don't add admin_menu actions for /wp-admin/?service-worker url WPcom_Admin_Menu: Add special cases that don't have menus extended Feb 11, 2022
@mreishus mreishus marked this pull request as ready for review February 11, 2022 22:03
@mreishus mreishus added [Status] Needs Team Review and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Status] In Progress labels Feb 11, 2022
@mreishus mreishus force-pushed the change/service-worker-admin-menu-action branch from 2b538b2 to f932a77 Compare February 11, 2022 22:14
@mreishus
Copy link
Contributor Author

For the PHP 8.1 WP master unit tests, I'm seeing this failure:

  Fatal error: Uncaught Error: Class "Requests_Cookie_Jar" not found in /tmp/wordpress-master/src/wp-includes/class-requests.php:591
  Stack trace:
  #0 /tmp/wordpress-master/src/wp-includes/class-requests.php(365): Requests::set_defaults()
  #1 /tmp/wordpress-master/src/wp-includes/class-wp-http.php(394): Requests::request()
  #2 /tmp/wordpress-master/src/wp-includes/class-wp-http.php(632): WP_Http->request()
  #3 /tmp/wordpress-master/src/wp-includes/http.php(162): WP_Http->get()
  #4 /tmp/wordpress-master/src/wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-a8c-mc-stats/src/class-a8c-mc-stats.php(140): wp_remote_get()
  #5 /tmp/wordpress-master/src/wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-a8c-mc-stats/src/class-a8c-mc-stats.php(127): Automattic\Jetpack\A8c_Mc_Stats->do_server_side_stat()
  #6 /tmp/wordpress-master/src/wp-content/plugins/jetpack/class.jetpack.php(4756): Automattic\Jetpack\A8c_Mc_Stats->do_server_side_stats()
  #7 /tmp/wordpress-master/src/wp-content/plugins/jetpack/class.jetpack.php(1142): Jetpack->do_stats()
  #8 /tmp/wordpress-master/src/wp-includes/class-wp-hook.php(303): Jetpack->push_stats()
  #9 /tmp/wordpress-master/src/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
  #10 /tmp/wordpress-master/src/wp-includes/plugin.php(470): WP_Hook->do_action()
  #11 /tmp/wordpress-master/src/wp-includes/load.php(1100): do_action()
  #12 [internal function]: shutdown_action_hook()
  #13 {main}
    thrown in /tmp/wordpress-master/src/wp-includes/class-requests.php on line 591
  Script tests/action-test-php.sh handling the test-php event returned with error code 255

I'm not sure if it's related to these changes?

@@ -35,6 +35,21 @@ function should_customize_nav( $admin_menu_class ) {
return false;
}

// WPCOM-specific exemptions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently maintain the Nav Unification activation logic for Simple sites in the wpcom codebase (in the show_unified_nav function which lives in wp-content/mu-plugins/masterbar.php), so I guess it makes sense to also add these new checks there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some testing (the patch is in D75746-code). It looks like it's another way to accomplish the same thing, either this PR or D75746-code is needed, but no extra benefit from both. Maybe D75746-code is better because it keeps the wpcom specific exemptions in wpcom and out of jetpack? I'd be fine w/ closing this PR and going for D75746-code.

2022-02-25_15-07
2022-02-25_15-08
2022-02-25_15-09
2022-02-25_15-10

Copy link
Member

@obenland obenland Feb 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think keeping wpcom's special case on wpcom in D75746-code makes sense. With WordPress/gutenberg#38810 about to be merged you could even keep it to just the *stuff.php file checks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be fine w/ closing this PR and going for D75746-code.

Let's do that then 🙂

@mreishus mreishus force-pushed the change/service-worker-admin-menu-action branch from f932a77 to 316b66c Compare February 25, 2022 21:17
@mreishus mreishus requested a review from mmtr February 25, 2022 21:34
@mreishus
Copy link
Contributor Author

Deployed D75746-code and made a note to remove the ?service-worker exemption after WordPress/gutenberg#38810 is merged

@mreishus mreishus closed this Feb 28, 2022
@mreishus mreishus deleted the change/service-worker-admin-menu-action branch February 28, 2022 19:21
@mreishus
Copy link
Contributor Author

mreishus commented May 19, 2022

Even though Gutenberg has removed the service worker, it's still installed in my browser and continues to make requests to /wp-admin/?service-worker=true. It seems safer to keep the workaround (D75746-code), unless there's a way to programmatically uninstall the service worker (I don't know of one).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Masterbar WordPress.com Toolbar and Dashboard customizations [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants