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

Add a mu-plugin loader that loads a specific version of a plugin if required. #561

Merged
merged 9 commits into from
Feb 1, 2024

Conversation

dd32
Copy link
Member

@dd32 dd32 commented Jan 25, 2024

Certain plugins on WordPress.org require specific versions of other plugins in order to operate.

One of these plugins is Blocks Everywhere, the current version of which requires Gutenberg 16.8.

We however use Gutenberg widely on other sites, and often want to use features from the recent versions.

This mu-plugin let's us load blocks-everywhere with Gutenberg 16.8, but use Gutenberg trunk/stable on other sites.

(edit: Obviously, this needs to be combined with an additional svn:external to have the plugin available)

@adamwoodnz
Copy link
Contributor

I tried running this in my sandbox and it works as described for the support forums. Unfortunately I run into the HTML API out of memory issues with the later version of Gutenberg on the rest of wporg. Any version 16.9.x on causes it.

@pkevan
Copy link
Contributor

pkevan commented Jan 26, 2024

Guessing I might have done something wrong in testing this, but it broke the support forums and deactivated the Gutenberg - i manually reactivated it to fix it.

What I did:

  • copy the changes from this PR
  • load the v16.8.0 version of Gutenberg through SVN external creating an additional copy of Gutenberg gutenberg-16.8
  • update the standard Gutenberg plugin external to 17.5.1
  • visit the forum site (front and back-end)

Unsure if the breakage was due to my method, or the way we attempt to override the sites' option values, as switching to non-sandbox mode didn't fix it.

Error:

Uncaught Error: Class 'WP_Theme_JSON_Data_Gutenberg' not found in /wp-content/plugins/blocks-everywhere/classes/class-editor.php:33

- attached to priority 10: Automattic\Blocks_Everywhere\Editor->wp_theme_json_data_theme

`array_splice` runs over the array in-place, and returns the extracted values, so this was setting the plugins list to just the from value.
…ugins

Gutenberg shows up in both sometimes, so we should check and remove from both.
I misunderstood what was happening, this does work
@ryelle
Copy link
Contributor

ryelle commented Jan 26, 2024

I pushed a few commits to fix some things I noticed:

  • array_splice runs over $plugins by reference, so we should return $plugins, not the array_splice result
  • In my testing, I had Gutenberg in both locally active and network active lists, so I split those into two checks

To test, I added a new folder gutenberg-16.8 on my sandbox, updated the main gutenberg to 17.5.2, and tried to load the Support Forums. The forum editor worked. I also tried loading other wporg sites, and looking at wp-admin. Other sites load Gutenberg 17.5.2, and the Support Forums load 16.8.1.

I assume there should be no effects on the WordCamp network, even though it won't have a gutenberg-16.8 folder, because it does not use Blocks Everywhere.

@ryelle
Copy link
Contributor

ryelle commented Jan 26, 2024

I tried running this in my sandbox and it works as described for the support forums. Unfortunately I run into the HTML API out of memory issues with the later version of Gutenberg on the rest of wporg. Any version 16.9.x on causes it.

@adamwoodnz I don't think I've ever run into this, but you've had memory issues with your sandbox before, right?

@adamwoodnz
Copy link
Contributor

I tried running this in my sandbox and it works as described for the support forums. Unfortunately I run into the HTML API out of memory issues with the later version of Gutenberg on the rest of wporg. Any version 16.9.x on causes it.

@adamwoodnz I don't think I've ever run into this, but you've had memory issues with your sandbox before, right?

That's true, but this is different. This was a production issue for some sites on the day of that slack post, and reproduced by others. If it's not an issue for anyone else now then I'll investigate further once shipped.

@dd32
Copy link
Member Author

dd32 commented Jan 28, 2024

  • array_splice runs over $plugins by reference, so we should return $plugins, not the array_splice result
  • In my testing, I had Gutenberg in both locally active and network active lists, so I split those into two checks

'doh! yeah array_splice() wasn't properly tested there for sure.. oops.

I hadn't considered it might be site-activated in network-activated contexts, but yeah it makes sense to do it like that.

I assume there should be no effects on the WordCamp network, even though it won't have a gutenberg-16.8 folder, because it does not use Blocks Everywhere.

That was the intention I had - That it would only kick in if the "problem" plugin existed, and that we'd have the environment setup for the plugin elsewhere. Realistically; having a non-existent plugin in the array isn't a problem, it would just mean the plugin isn't loaded at all.

Thanks @ryelle!

@dd32
Copy link
Member Author

dd32 commented Jan 28, 2024

A thought I had over the weekend:
This should probably return early on wp-admin/plugins.php, or the option filters should cease functioning once plugins_loaded has fired.

That would avoid future people attempting to "switch to the newer version of gutenberg" via wp-admin/plugins.

@ryelle
Copy link
Contributor

ryelle commented Jan 29, 2024

Looks like we'll want this for the pattern directory, pattern-creator/pattern-creator.php, it has the same issue as Blocks Everywhere (using private APIs).

@ryelle ryelle marked this pull request as ready for review January 31, 2024 19:38
…oid the filtered array being saved and becoming un-filtered.
@dd32
Copy link
Member Author

dd32 commented Feb 1, 2024

I tried running this in my sandbox and it works as described for the support forums. Unfortunately I run into the HTML API out of memory issues with the later version of Gutenberg on the rest of wporg. Any version 16.9.x on causes it.

I've run into this as well, only on block theme sites though (ie. wordpress.org/showcase or https://developer.wordpress.org/, but not w.org/plugins) with GB 16.9~17.2. 17.3 appears to be the first version that works without running into memory exhaustion.

I'm guessing that's either a fixed bug, or an incompatibility between WordPress trunk and those versions of Gutenberg.

I'm going to merge this, I was going to bump the main deployed gutenberg to 17.1 as well since the interactivity changes were after that, but I'll hold off on that bump due to the above memory issues.

The Interactivity PRs can then be merged, the main Gutenberg version increased, and both deployed at once.

@dd32 dd32 merged commit 9e39b9a into trunk Feb 1, 2024
2 checks passed
@dd32 dd32 deleted the add/incompatible-plugins-plugin branch February 1, 2024 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants