Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

dev: Add SemVer-compatible updater #359

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

justlevine
Copy link

@justlevine justlevine commented Jun 24, 2023

This PR (wip) adds a forward-compatible plugin updater to help transition to the new wp-graphql/wpgraphql-acf version and WordPress.org distribution.

When completed the plugin will

  • Disable auto-updates for breaking releases.
  • Display an inline-notice on the Upgrades/Plugins screen when a plugin update is a breaking release.
  • Add a confirmation modal when upgrading is a breaking release.
  • Preventing updating from v0.x.y to v2.x.y, so the 2.0 release on wp.org doesnt autoupdate to a breaking change.

To do

  • Backport and scaffold Updater class.
  • Add thickbox model controls and styling.
  • (Maybe) Add mechanism to auto-downgrade from v2.0 to v1.x if autoupdated from a version without this Updater functionality.
  • Test.
  • Repurpose for 2.x codebase

Release process:

  1. This should be pushed in a 0.x.Y release (to catch anyone installing with composer).
  2. A cosmetic v1.0 release will be pushed as the first WordPress.org release (to catch anyone using WordPress's autoupdater)
  3. The new v2.0 codebase in https://github.com/wp-graphql/wpgraphql-acf will then be released to WordPress.org, where a warning about the breaking changes will be included (and users will be prompted to confirm before updating).
  4. (Maybe) if a user autoupdates from < 0.current to 2.0, they will be automatically downgraded to v1.0 (step 2+3)

To test:

Since the plugin is not yet on WP.org, we can use the following filters to test. This essentially 'tricks' WordPress into thinking that the latest WPGraphQL core update is actually for our plugin.

//Disable after testing.
add_filter( 'plugins_api_args', static function ( $args ) {
	if ( isset( $args->slug ) && $args->slug === 'wp-graphql-acf' ) {
		$args->slug = 'wp-graphql';
	}

	return $args;
} );
add_filter( 'wpgraphql_acf_wporg_api_url', static function () {
	return 'https://api.wordpress.org/plugins/info/1.0/wp-graphql.json';
}  );
add_filter( 'wpgraphql_acf_wporg_api_result_slug', static function ( $slug, $args ) {
	return 'wp-graphql';
}, 10, 2  );

Screenshots

  1. Update screen notice:
    image
  2. Update screen modal : todo
  3. Plugin screen notice:
    image
  4. Plugin information modal notice (appears on every tab)
    image

@jasonbahl
Copy link
Contributor

@justlevine with the provided snippet:

//Disable after testing.
add_filter( 'plugins_api_args', static function ( $args ) {
	if ( isset( $args->slug ) && $args->slug === 'wp-graphql-acf' ) {
		$args->slug = 'wp-graphql';
	}

	return $args;
} );
add_filter( 'wpgraphql_acf_wporg_api_url', static function () {
	return 'https://api.wordpress.org/plugins/info/1.0/wp-graphql.json';
}  );
add_filter( 'wpgraphql_acf_wporg_api_result_slug', static function ( $slug, $args ) {
	return 'wp-graphql';
}, 10, 2  );

I'm not seeing what you see in your screenshot. I still see the core WPGraphQL update notice:

CleanShot 2023-07-05 at 11 44 30

@justlevine
Copy link
Author

@jasonbahl my (untested) guess would be that since there's an actual WPGraphQL update, the hacky snippet (needed to mock the response) is getting deduped and only one plugin is showing. Does it work if you change it to woocommerce / woocommerce.json (or anything other .org plugin you don't have installed locally)?

If not, ping me and ill test it later tonight.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants