Skip to content

Beta plugin: Support managing multiple plugins#20168

Merged
kraftbj merged 27 commits into
masterfrom
add/beta-plugin-multiple-plugins
Jul 12, 2021
Merged

Beta plugin: Support managing multiple plugins#20168
kraftbj merged 27 commits into
masterfrom
add/beta-plugin-multiple-plugins

Conversation

@anomiex
Copy link
Copy Markdown
Contributor

@anomiex anomiex commented Jun 24, 2021

Changes proposed in this Pull Request:

We want to be able to support testing plugins other than Jetpack, such as the upcoming Jetpack Backup plugin. We've already changed the build, and the change to the Beta Download website is pending. This updates the plugin itself.

Jetpack product discussion

p9dueE-362-p2

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

No.

Testing instructions:

  • Create a JN site, with Jetpack and Jetpack Beta but not VaultPress.
  • SSH in to the JN site, and check this out:
    • git clone --branch add/beta-plugin-multiple-plugins --depth=20 https://github.com/Automattic/jetpack
    • cd jetpack/projects/plugins/beta/
    • composer install
    • cd ~/apps/$USER/public/wp-content/plugins
    • rm -rf jetpack-beta
    • ln -s ~/jetpack/projects/plugins/beta jetpack-beta
  • Try using it to manage the plugins.
    • Switch between various versions of Jetpack.
    • Install "Bleeding Edge" VaultPress.
    • Go to the plugins page and disable VaultPress. It should completely disappear, since no "stable" version has been installed.
    • Install an old version of Jetpack. See that it shows that updates are available in JP Beta's management pages. See that the "Update" buttons there work.
    • Install a PR branch for a plugin, then update the PR in GitHub. See that it shows that updates are available in JP Beta's management pages. See that the "Update" buttons there work.
  • Create another JN site, this time with multisite enabled. Set it up with JPBeta from this PR as above.
    • Enable Jetpack at the site level. Things should work exactly as above.
    • Enable Jetpack sitewide. All links to the JPBeta management page for Jetpack should now point to Network Admin rather than regular admin. Attempting to go to the regular admin URL should redirect to Network Admin.

@anomiex anomiex added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress [Pri] Normal labels Jun 24, 2021
@anomiex anomiex self-assigned this Jun 24, 2021
@github-actions github-actions Bot added the [Plugin] Beta For serving live branches and the beta versions. https://github.com/automattic/jetpack-beta label Jun 24, 2021
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 24, 2021

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.


Beta plugin:

  • Next scheduled release: August 3, 2021.
  • Scheduled code freeze: July 26, 2021.

@anomiex anomiex force-pushed the add/beta-plugin-multiple-plugins branch 4 times, most recently from 22952e0 to 8c6ee25 Compare July 1, 2021 17:26
@anomiex anomiex force-pushed the add/beta-plugin-multiple-plugins branch from 8d2b819 to 73a755f Compare July 6, 2021 19:15
@github-actions github-actions Bot added Actions GitHub actions used to automate some of the work around releases and repository management Docs labels Jul 7, 2021
anomiex added 17 commits July 7, 2021 13:28
JPBETA__PLUGIN_FILE and JPBETA_DEFAULT_BRANCH are unused.

Several others assume Jetpack; group them for deletion.
Eventually all the stuff that varies by plugin will live here.
This one was pretty ok to start with.

- Declare a field that was being used.
- Fix up doc blocks.
- Remove some unnecessary two-line functions, which lets us get rid of
  another field.
- Remove some unneeded `empty()` calls.
- Simplify a weirdly overcomplicated conditional.
- Privatize methods that aren't used externally.
- Rename a misspelled method, `has_never_version` → `has_newer_version`.
- Fix semantics in `plugins_api` filter method `get_plugin_info()`.
- Document why `upgrader_source_selection` is being filtered at all.
The `activate` command won't work yet, because I haven't written the
method to actually do the installation. Other than that it should work.
If we're going to try to delete transients, let's try to get them all.
So rename the ones from the self-autoupdater to use a common prefix with
the rest of the extension, then select the list of transients from the
database.
The menu option wasn't being added if Jetpack (not Beta) was
network-activated, I guess for access control. In a multiple-plugin
world, we'll need to do that access control inside the admin page based
on the plugin selected.

Similarly, Utils::admin_url() was generating links to regular Admin or
Network Admin based on whether Jetpack (not Beta) was network-activated.
That too will need to depend on if it's generating a link to the
"manage" page for a network-activated plugin or not.

Several hooks needed updating for a multiple-plugin world where some
might be network-activated and some might not be.

To avoid potential network hits on every page load from those hooks if
transients are being particularly transient, cache a map of known plugin
files in the options.

There's still one use left in Utils::replace_active_plugin(); that needs
refactoring anyway, so I'll get rid of the last use when I do that.
Just return false, the standard handler does the right thing (since PHP
4.3.10!).
Creates a PluginInstaller class to hold that logic instead.

One call remains, from the UI.

This also gets rid of Utils::update_plugin(), also in the UI.

And we clean up Hooks::deactivate() to handle multiple plugins.
And link to Network Admin if applicable.
Changes of note:

* Got rid of the JETPACK_GREEN constant, because we need different
  greens in different places.
   * Logo changed to Green 40, per https://git.io/JcWou
   * Admin bar highlight color changed to Green 50, per pcdRpT-if-p2
* The admin bar menu gets an extra level.
* The autoupdater email loses the attempt at "what changed?" and testing
  instructions. It would be too much if multiple plugins get updated.
  Instead, each plugin listed has a link to the PR or mirror repo branch.
* Pulling in composer/semver to compare versions, since PHP's
  `version_compare()` doesn't really work right.
I decided to more heavily use "template" files rather than embedding
`<?php ?>` in the class file.

I still need to do something about Admin::to_test_content() and
Utils::what_changed(), and go through to remove now-unused methods.
And merge Utils::what_changed() into it.

Also, instead of using Jetpack's markdown library when it happens to be
available, just pull in one that explicitly handles GitHub-Flavored
Markdown.
@anomiex anomiex force-pushed the add/beta-plugin-multiple-plugins branch from 0f73b06 to 469750c Compare July 7, 2021 17:29
@anomiex anomiex force-pushed the add/beta-plugin-multiple-plugins branch from 469750c to 2ef4293 Compare July 7, 2021 17:34
For example, if the -dev dir was left from an older version of Jetpack
Beta.
@anomiex anomiex force-pushed the add/beta-plugin-multiple-plugins branch from 8cd5063 to 3eeb04e Compare July 7, 2021 17:59
Mostly to prevent the possibility of accidentally managing a
network-enabled plugin when our hook for preventing duplicate versions
can't run in time.
@anomiex anomiex marked this pull request as ready for review July 7, 2021 18:44
@anomiex anomiex added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jul 7, 2021
Copy link
Copy Markdown
Contributor

@kraftbj kraftbj left a comment

Choose a reason for hiding this comment

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

It would be nice to have a gentle fail if someone activates the plugin without running composer install (like we do for jetpack itself), but that isn't blocking. Let's merge it!

@kraftbj kraftbj added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Jul 12, 2021
@kraftbj kraftbj merged commit 1811475 into master Jul 12, 2021
@kraftbj kraftbj deleted the add/beta-plugin-multiple-plugins branch July 12, 2021 20:56
@github-actions github-actions Bot added this to the beta/2.4.7 milestone Jul 12, 2021
@github-actions github-actions Bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Jul 12, 2021
samiff added a commit that referenced this pull request Jul 16, 2021
After PR: #20168

There were a few element not found errors since the plugin layout was
adjusted; this PR cleans those errors up.
anomiex pushed a commit that referenced this pull request Jul 19, 2021
After PR: #20168

There were a few element not found errors since the plugin layout was
adjusted; this PR cleans those errors up.
matticbot pushed a commit to Automattic/jetpack-beta that referenced this pull request Jul 19, 2021
After PR: Automattic/jetpack#20168

There were a few element not found errors since the plugin layout was
adjusted; this PR cleans those errors up.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/1045899249
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Actions GitHub actions used to automate some of the work around releases and repository management Docs Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Plugin] Beta For serving live branches and the beta versions. https://github.com/automattic/jetpack-beta [Pri] Normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants