-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
If the Legacy REST API plugin is auto-installed once, do not auto-install a second time. #47563
If the Legacy REST API plugin is auto-installed once, do not auto-install a second time. #47563
Conversation
…tall a second time.
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
Hi @jorgeatorres, @Konamiman, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
…eed in a sitewide option).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use the woocommerce_autoinstalled_plugins
option for this, because the information in this option is deleted if the plugin is reinstalled manually. We need to use a different option, something like woocommerce_history_of_autoinstalled_plugins
.
This option holds the same data as woocommerce_autoinstalled_plugins, the difference is that the data in this new option is never deleted. It's also never updated, it just holds the information of the first autoinstall for each plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the amendments!
☑️ 8.8.0 → 8.9.0 (legacy plugin installed, then deleted) → this branch (legacy plugin not installed a second time)
☑️ 8.8.0 → straight to this branch (legacy plugin installed)
📝 Noting I am currently reliant on testing via JN, as I'm currently having some build problems with the mono-repo locally.
@Konamiman there was a side discussion about simplifying this down, so that the auto-installation logic is simply contained in a regular migration (in wc-update-functions.php
).
This might avoid us having to track the auto-installation history, because (typically) that migration function will only be executed once, whenever a user upgrades to or past the specified version. Could this reduce complexity?
I'm also quite happy to move ahead with the current approach, so we can expedite inclusion in the upcoming release—but wanted to run this by you.
…tall a second time. (#47563) * If the Legacy REST API plugin is auto-installed once, do not auto-install a second time. * Remove unused private constant (PluginInstaller records the info we need in a sitewide option). * Introduce the woocommerce_history_of_autoinstalled_plugins option This option holds the same data as woocommerce_autoinstalled_plugins, the difference is that the data in this new option is never deleted. It's also never updated, it just holds the information of the first autoinstall for each plugin. * Add a migration to create woocommerce_history_of_autoinstalled_plugins * More robust check of previous autoinstall of the plugin * Change migration to run in 8.9.1 instead of 9.0.0 --------- Co-authored-by: Nestor Soriano <konamiman@konamiman.com>
* If the Legacy REST API plugin is auto-installed once, do not auto-install a second time. (#47563) * If the Legacy REST API plugin is auto-installed once, do not auto-install a second time. * Remove unused private constant (PluginInstaller records the info we need in a sitewide option). * Introduce the woocommerce_history_of_autoinstalled_plugins option This option holds the same data as woocommerce_autoinstalled_plugins, the difference is that the data in this new option is never deleted. It's also never updated, it just holds the information of the first autoinstall for each plugin. * Add a migration to create woocommerce_history_of_autoinstalled_plugins * More robust check of previous autoinstall of the plugin * Change migration to run in 8.9.1 instead of 9.0.0 --------- Co-authored-by: Nestor Soriano <konamiman@konamiman.com> * Prep for cherry pick 47563 --------- Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com> Co-authored-by: Nestor Soriano <konamiman@konamiman.com> Co-authored-by: WooCommerce Bot <no-reply@woocommerce.com>
Currently:
This change makes it so automated installation only happens once. Therefore, if the plugin is subsequently removed merchants will A) need to manually re-install it if desired B) won't have to manually remove it on subsequent plugin updates.
To achieve this, these code changes are implemented:
PluginInstaller
will now maintain a new option,woocommerce_history_of_autoinstalled_plugins
, in addition to the already existingwoocommerce_autoinstalled_plugins
. Both contain the same information, the difference is that the information in the new option is never deleted (the information in the old option is deleted if the plugin is manually reinstalled).PluginInstaller::maybe_install_legacy_api_plugin
will now check if the Legacy REST API plugin is listed in either of the options (the new one should be enough, we check the old one too for robustness) and if so the plugin won't be installed (thewoocommerce_skip_legacy_rest_api_plugin_auto_install
filter still works as expected).How to test the changes in this Pull Request:
Testing the usual flow
Setup:
Special note for those using Jurassic Ninja: if you start with the latest version of WooCommerce, that's fine, but make sure you:
wp option set woocommerce_version 8.8.0
From there:
Testing the manual reinstall flow
From the current state:
wp option get woocommerce_autoinstalled_plugins
, it should say that the option doesn't exist.wp option get woocommerce_history_of_autoinstalled_plugins
, you should get the plugin information.wp option set woocommerce_version 8.8.0
🔌 woocommerce.zip (pre-built plugin zip for this branch—last updated 2024-05-17 13:30 UTC)