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

Jetpack: clean up registration_nonce #42552

Merged
merged 3 commits into from
Mar 25, 2025

Conversation

sergeymitr
Copy link
Contributor

@sergeymitr sergeymitr commented Mar 18, 2025

Part of #42076

Proposed changes:

  • Remove the registration_nonce remnants from the Jetpack plugin.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

PT: pf5801-1dm-p2
Justification: pf5801-1q1-p2#comment-787

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

No.

Testing instructions:

Connection

  1. Disconnect Jetpack.
  2. If testing locally, make sure to rebuild both plugins/jetpack and packages/connection.
  3. Connect Jetpack from "Jetpack -> Jetpack", confirm it works well.
  4. Unlink your user account to leave the site in site-only mode.
  5. Go to Jetpack Dashboard and establish the user connection. Confirm it works well.
  6. Disconnect Jetpack.

Coupons

  1. Follow PCYsg-aB2-p2 to create a coupon code in format NONCE_NON_ + random letters.
  2. Add the following filters to your local site:
add_filter( 'jetpack_partner_coupon_supported_partners', function( $partners ) {
	$partners['NONCE'] = array(
		'name' => 'NONCE',
		'logo' => array(
			'src'    => '/images/jetpack-icon.jpg',
			'width'  => 119,
			'height' => 32,
		),
	);
	return $partners;
} );

add_filter( 'jetpack_partner_coupon_supported_presets', function( $presets ) {
	$presets['NON'] = 'jetpack_backup_daily';
	return $presets;
} );
  1. Go to the connection page with coupon code added to the URL: /wp-admin/admin.php?page=jetpack&jetpack-partner-coupon=the-coupon-code
  2. Confirm that you see the coupon connecting screen.
  3. Connect Jetpack. Confirm it works well.
  4. Go to the same URL, now with the connected Jetpack. Confirm that you see the "Redeem coupon" screen.
  5. Click "Redeem", confirm you get redirected to the checkout page.

WooCommerce

  1. Disconnect Jetpack, install WooCommerce
  2. Go to the Woo connection screen: /wp-admin/admin.php?page=jetpack#/woo-setup
  3. Confirm you see the Woo connection screen. Follow the connection flow, confirm it works well.

@sergeymitr sergeymitr self-assigned this Mar 18, 2025
@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests Admin Page React-powered dashboard under the Jetpack menu labels Mar 18, 2025
Copy link
Contributor

github-actions bot commented Mar 18, 2025

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.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: April 1, 2025
    • Code freeze: March 30, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Contributor

github-actions bot commented Mar 18, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the remove/site-registration-nonce-jetpack branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack remove/site-registration-nonce-jetpack

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link

jp-launch-control bot commented Mar 18, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/service-api-keys.php 129/176 (73.30%) 3.41% -6 💚

Full summary · PHP report · JS report

@sergeymitr sergeymitr added this to the jetpack/14.5 milestone Mar 18, 2025
@sergeymitr sergeymitr added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Mar 19, 2025
Copy link
Contributor

@coder-karen coder-karen left a comment

Choose a reason for hiding this comment

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

Tested well for me, though I had a question around one testing step.
/wp-admin/admin.php?page=jetpack&jetpack-partner-coupon=my-coupon-code
redirects to /wp-admin/admin.php?page=jetpack and shows 'Setup and redeem Jetpack Backup'. I presume that was what I was supposed to click?
I can't then go back to that URL afterwards, as it just redirects to /wp-admin/admin.php?page=jetpack&showCouponRedemption=1#/dashboard.

Also, for some reason, it looks as though this PR introduces a new PHP error: PHP Notice: Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>woocommerce</code> domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the <code>init</code> action or later. Please see <a href="https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.7.0.) in /var/www/html/wp-includes/functions.php on line 6121. I changed between trunk and the PR a few times just to double check it wasn't also happening on trunk. It happens specifically after going through the connection process just before being redirected back to the site. I added a stack trace, the first part of which shows:

Stack trace:
#0 /var/www/html/wp-includes/l10n.php(1412): _load_textdomain_just_in_time()
#1 /var/www/html/wp-includes/l10n.php(195): get_translations_for_domain()
#2 /var/www/html/wp-includes/l10n.php(307): translate()
#3 /usr/local/src/jetpack-monorepo/projects/packages/assets/src/class-assets.php(664): __()
#4 /var/www/html/wp-includes/class-wp-hook.php(324): Automattic\Jetpack\Assets::filter_gettext()
#5 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#6 /var/www/html/wp-includes/l10n.php(220): apply_filters()
#7 /var/www/html/wp-includes/l10n.php(307): translate()
#8 /usr/local/src/jetpack-monorepo/projects/packages/connection/src/class-tokens.php(381): __()
#9 /usr/local/src/jetpack-monorepo/projects/packages/connection/src/class-manager.php(488): Automattic\Jetpack\Connection\Tokens->get_access_token()
#10 /usr/local/src/jetpack-monorepo/projects/packages/connection/src/class-manager.php(401): Automattic\Jetpack\Connection\Manager->internal_verify_xml_rpc_signature()
#11 /usr/local/src/jetpack-monorepo/projects/packages/connection/src/class-manager.php(130): Automattic\Jetpack\Connection\Manager->verify_xml_rpc_signature()
#12 /usr/local/src/jetpack-monorepo/projects/packages/config/src/class-config.php(266): Automattic\Jetpack\Connection\Manager::configure()
#13 /usr/local/src/jetpack-monorepo/projects/packages/config/src/class-config.php(217): Automattic\Jetpack\Config->enable_connection()
#14 /usr/local/src/jetpack-monorepo/projects/packages/config/src/class-config.php(107): Automattic\Jetpack\Config->ensure_feature()
#15 /var/www/html/wp-includes/class-wp-hook.php(324): Automattic\Jetpack\Config->on_plugins_loaded()

Do you see the warning as well in testing locally as well?
Edit to add - I've realized the reason I see the warning is because I'm testing with WordPress 6.8 in my local dev environment, so you may need to add the WordPress Beta Tester plugin and upgrade to the latest beta as well, assuming your test site uses English as it's site language?. Or change the site language to something like Deutsch, and reinstall the current version, that may also work.

@sergeymitr sergeymitr added [Status] In Progress and removed [Status] Needs Review This PR is ready for review. labels Mar 21, 2025
@sergeymitr
Copy link
Contributor Author

Hi @coder-karen, thanks for taking a look!

I can't then go back to that URL afterwards, as it just redirects to /wp-admin/admin.php?page=jetpack&showCouponRedemption=1#/dashboard.

As far as I can tell, it's supposed to happen for connected sites.
You should see a different coupon redeeming screen after getting connected. It doesn't seem to show up in site-only mode though, so you'd need to connect user as well.
Screenshot 2025-03-21 at 13 21 17

Also, for some reason, it looks as though this PR introduces a new PHP error: PHP Notice: Function _load_textdomain_just_in_time was called incorrectly.

I tried to reproduce it on 6.8-beta3-60060 with no luck, the error log is clean.
I can't think of a reason why it might start showing up, the we only clean up some code in the PR, we don't add anything new.

@sergeymitr sergeymitr added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Mar 21, 2025
@coder-karen
Copy link
Contributor

I tried again on my local development site, same results, also still see the PHP error. To confirm, I made sure I rebuilt Jetpack and Connection locally after checking out the PR, this time rebuilding all dependencies associated with Jetpack just in case.

So then I tried just now on a Jurassic Ninja site, everything worked as I'd expect, based on the testing instructions. Except for step 5 under 'Coupons' - after going through the connection flow and landing back on the site I land on the dashboard and see a notice 'Your connection with WordPress.com seems to be broken. If you're experiencing issues, please try reconnecting.', maybe that's unrelated?

I also don't see the PHP error on a Jurassic Ninja site. So, the issues seem to either be related to local development environment, or just mine.

For what it's worth, it's just one PHP notice each connection, so it will not be filling up logs. If it isn't replicable, then it would seem fairly safe to wait and see if we can replicate later I think?

@sergeymitr
Copy link
Contributor Author

So then I tried just now on a Jurassic Ninja site, everything worked as I'd expect, based on the testing instructions. Except for step 5 under 'Coupons' - after going through the connection flow and landing back on the site I land on the dashboard and see a notice 'Your connection with WordPress.com seems to be broken. If you're experiencing issues, please try reconnecting.', maybe that's unrelated?

It does seem unrelated. Since we edit UI for the most part, it seems unlikely to trigger connection issues.
I wasn't able to reproduce that, but will keep an eye on it if I manage to catch it in the future.

If it isn't replicable, then it would seem fairly safe to wait and see if we can replicate later I think?

I agree, let's keep an eye on that. This too doesn't seem related to the PR though, since we are only removing stuff and don't edit any initialization flows.

@sergeymitr sergeymitr removed this from the jetpack/14.5 milestone Mar 25, 2025
Copy link
Contributor

@coder-karen coder-karen left a comment

Choose a reason for hiding this comment

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

Ok, thanks for clarifying! In that case, giving this a ✅

@sergeymitr sergeymitr merged commit c868dde into trunk Mar 25, 2025
63 checks passed
@sergeymitr sergeymitr deleted the remove/site-registration-nonce-jetpack branch March 25, 2025 12:14
@github-actions github-actions bot added this to the jetpack/14.5 milestone Mar 25, 2025
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin Page React-powered dashboard under the Jetpack menu [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests [Type] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants