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 9.6.1 loads old classes during WooCommerce setup #19624

Open
waclawjacek opened this issue Apr 22, 2021 · 8 comments
Open

Jetpack 9.6.1 loads old classes during WooCommerce setup #19624

waclawjacek opened this issue Apr 22, 2021 · 8 comments
Assignees
Labels
[Package] Autoloader [Pri] High [Status] In Progress [Type] Bug When a feature is broken and / or not performing as intended

Comments

@waclawjacek
Copy link
Contributor

Steps to reproduce the issue

As reported in Automattic/woocommerce-payments#1663, there is an error that can be observed when installing Jetpack using WooCommerce's setup flow. This issue is only present on Jetpack ≥ 9.6.

For some more details on how this relates to WooCommerce and WooCommerce Payments (incl. how and why the error doesn't happen on older WC versions), please see the link above.

I am seeing the error on:

  • Jetpack 9.6.1 (also on 9.6).
  • WordPress 5.7.1.
  • WooCommerce 5.2.2.

(The version of WooCommerce Payments installed by the WooCommerce setup wizard is 2.3.0.)

The error can be replicated by:

  1. Installing WooCommerce on a new site (and nothing else).
  2. Going through the onboarding flow, selecting WCPay and Jetpack as the plugins to install.
  3. The installation will fail but leave this page open.
  4. In a new tab, go to the Plugins page. WCPay will be enabled, Jetpack will be installed but disabled.
  5. Remove the installed version of Jetpack and replace it with Jetpack 9.5.2.
  6. Click Retry in the tab with the WC onboarding.
  7. Setup will continue.

Alternatively, this flow can be tested by first installing Jetpack 9.5.2 (regardless of whether it's active) and then attempting the onboarding in which case there will be no error at any point of the process.

What I expected

Jetpack is installed successfully during the WooCommerce setup flow.

What happened instead

An error is shown and the installation doesn't proceed.

Screenshots

WooCommerce setup error

@waclawjacek waclawjacek added [Type] Bug When a feature is broken and / or not performing as intended [Pri] High labels Apr 22, 2021
@jrodger
Copy link

jrodger commented Apr 22, 2021

In case it helps, WooCommerce Payments is using version 2.8.0 of the Jetpack autoloader.

@jeherve
Copy link
Member

jeherve commented Apr 22, 2021

cc @ObliviousHarmony @kbrown9, in case something comes to your mind.

@kbrown9
Copy link
Member

kbrown9 commented Apr 22, 2021

I'm trying to reproduce the problem, but I'm not sure how to get to step 2:

  1. Installing WooCommerce on a new site (and nothing else).
  2. Going through the onboarding flow, selecting WCPay and Jetpack as the plugins to install.

I don't see a screen plugin install screen that shows WCPay and Jetpack in the onboarding flow. I'm running Woo 5.2.2.

@kbrown9
Copy link
Member

kbrown9 commented Apr 22, 2021

Based on this comment about the cause of the Jetpack activation failure, I wonder if WCPay is loading a package class before the autoloader is aware that Jetpack is activated.

@waclawjacek
Copy link
Contributor Author

@kbrown9:

I don't see a screen plugin install screen that shows WCPay and Jetpack in the onboarding flow. I'm running Woo 5.2.2.

On a fresh install, this should be displayed when you go to WooCommerce > Home. If it isn't, you can force going through the setup flow by going to WooCommerce > Products > Help (top right) > Setup wizard > Setup wizard.

The store details I am testing for are:

Test Street 123, Test City
US, California, 94110

@kbrown9
Copy link
Member

kbrown9 commented Apr 22, 2021

I was able to reproduce the problem using the store details provide above.

Here's what's happening:

  1. Woo's onboarding flow sends a request to activate woocommerce-payments and Jetpack, in that order (see this comment).
  2. The two plugins are activated here, one after the other.
  3. WooCommerce Payments activates first and loads the autoloader. The autoloader finds the packages associated with the currently active plugins and chooses the latest package versions. Note that Jetpack isn't active yet, so the autoloader doesn't look at it.
  4. WooCommerce Payments loads a few connection package files right after activating.
  5. Jetpack activates. Jetpack needs the latest connection package files, but an older version of those files was already loaded for WooCommerce Payments.

The problem is that the autoloader can't anticipate that Jetpack is about to be activated. WooCommerce could reorder the plugins so that Jetpack is activated first (which was tested in this comment), and that should fix the immediate problem. However, the problem could occur again if, for example, WC Pay was activated second and needed a newer version of the connection package.

The autoloader does attempt to identify activating plugins and treat them as active plugins here. It might be possible to intercept WooCommerce's plugin activation request and preemptively add the activating plugins to the active list.

@tammullen
Copy link

Is it possible to raise the priority of this? It impacts the critical flows of WooCommerce (Merchant Can go through Setup Wizard) and WC Pay (Merchant can Onboard via WooCommerce setup wizard).

cc:@kbrown9

@kbrown9
Copy link
Member

kbrown9 commented May 7, 2021

Hi @tammullen! I have a PR in progress for this issue in #19634, and I've requested a review from @ObliviousHarmony on that PR. Also, I see that Woo has a PR in progress to change the WCPay/Jetpack activation order in this PR, which should fix the bug you're experiencing in the critical flows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Autoloader [Pri] High [Status] In Progress [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants