Skip to content

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

Description

@alpipego

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions