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

Require wordpress/core-implementation and php as defined by the plugin #516

Open
alpipego opened this issue Feb 23, 2024 · 4 comments
Open

Comments

@alpipego
Copy link

alpipego commented Feb 23, 2024

Hello,
I've long noticed a potential area for improvement concerning compatibility checks with PHP versions and specific WordPress core versions. Currently, developers need to manually ensure that their WordPress environment matches the requirements of the plugins and themes they incorporate.

Example

Let's assume my project has this composer.json:

{
  "name": "alpipego/test",
  "description": "Testing core and PHP requirements",
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org",
      "canonical": true,
      "only": [
        "wpackagist-plugin/*",
        "wpackagist-theme/*"
      ]
    }
  ],
  "require": {
    "johnpbloch/wordpress-core": "5.4.*",
    "johnpbloch/wordpress-core-installer": "^2.0",
    "wpackagist-plugin/query-monitor": "^3.2.2"
  },
  "config": {
    "platform": {
      "php": "7.0"
    },
    "allow-plugins": {
      "composer/installers": true,
      "johnpbloch/wordpress-core-installer": true
    }
  },
  "extra": {
    "wordpress-install-dir": "public/wp",
    "installer-paths": {
      "public/wp-content/mu-plugins/{$name}/": [
        "type:wordpress-muplugin"
      ],
      "public/wp-content/plugins/{$name}/": [
        "type:wordpress-plugin"
      ],
      "public/wp-content/themes/{$name}/": [
        "type:wordpress-theme"
      ]
    }
  }
}

As of writing, this will install WordPress core in version 5.4.15 and Query Monitor in version 3.15.0. However, the installed Query Monitor version requires at least WordPress 5.6 and PHP 7.4, neither of which are satisfied in the current project configuration.

This is the header for the installed QM version:

# Query Monitor
Contributors: johnbillion
Tags: debug, debug-bar, development, performance, query monitor, rest-api
Requires at least: 5.6
Tested up to: 6.4
Stable tag: 3.15.0
License: GPLv2 or later
Requires PHP: 7.4
Donate link: https://github.com/sponsors/johnbillion

Suggestion

  • Implement a feature within WPackagist that automatically checks and enforces compatibility based on the Requires at least field provided by the WordPress.org Plugin/Theme API for the WordPress version and Requires PHP for the PHP version.
  • Require wordpress/core-implementation for WordPress core (https://packagist.org/providers/wordpress/core-implementation)

Potential Breaking Change

While this proposal aims to improve compatibility checks, it's crucial to consider the potential for breaking changes in websites that currently do not install a WordPress core package that provides wordpress/core-implementation.


I haven't looked into https://github.com/WordPress/wp-plugin-dependencies deeply, but I assume it's something that could/should be considered down the line.

@NoelLH
Copy link
Contributor

NoelLH commented Mar 4, 2024

Definitely sounds like a good improvement, although I suppose it might also cause trouble with stale but working plugins if the compatibility metadata is listed as compulsory (rather than in e.g. suggests)?

I wasn't sure from the main docs if the fields are exposed in the API but this comment suggests they should be.

@ethanclevenger91
Copy link

I believe there are a couple potential packages for pulling in WP core, so it may not be feasible to enforce a specific one.

@alpipego
Copy link
Author

@ethanclevenger91 please check the following from my proposal. wordpress/core-implementation is not one specific implementation, but rather a meta package that is provided by other packages. If you click on the link, you can see the packages that provide wordpress/core-implementation.

Require wordpress/core-implementation for WordPress core (https://packagist.org/providers/wordpress/core-implementation)

@ethanclevenger91
Copy link

@alpipego oh sick, learned something new today!

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

No branches or pull requests

3 participants