Remove Drupal::CORE_COMPATIBILITY because it is not accurate when modules can be compatible with multiple core branches

Created on 3 October 2019, over 4 years ago
Updated 15 March 2023, over 1 year ago

Problem/Motivation

Drupal::CORE_COMPATIBILITY is used in many places throughout to filter on core compatibility. Historically this has all corresponded to project branch and version names with the 8.x- prefix

Now that #2313917: Core version key in module's .info.yml doesn't respect core semantic versioning β†’ has been committed projects and specify that they are compatible with multiple versions of core using the core_version_requirement key in info.yml files

Proposed resolution

Completely remove this constant if possible, remove from any many uses as possible if not.

Remaining tasks

Identify all the issues for usages

  1. #3074993: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates β†’
  2. #3016471: Make localization file download major version agnostic β†’

It may be too late to deprecate this const in 8.x so it might have to wait until 9.x.

User interface changes

There are few places where it is used in message shown to the user. Determine if those message will change or the MAJOR_VERSION.x will be derived from different sources but the message will remain the same.

API changes

TBD

Data model changes

TBD

Release notes snippet

πŸ“Œ Task
Status

Active

Version

10.1 ✨

Component
BaseΒ  β†’

Last updated 1 minute ago

Created by

πŸ‡ΊπŸ‡ΈUnited States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States dww

    +1 to removing this constant. To get the ball rolling, here are all 7 of the occurrences of 'CORE_COMPAT' in 10.1.x branch of core.

  • πŸ‡ΊπŸ‡ΈUnited States dww

    Some initial thoughts on the above list...

    1. core/includes/update.inc:          $ret[$module]['warning'] = '<em>' . $module . '</em> module cannot be updated. It contains an update numbered as ' . \Drupal::CORE_MINIMUM_SCHEMA_VERSION . ' which is reserved for the earliest installation of a module in Drupal ' . \Drupal::CORE_COMPATIBILITY . ', before any updates. In order to update <em>' . $module . '</em> module, you will need to install a version of the module with valid updates.';
      

      This is fully wrong. πŸ˜‰ IMHO, it should be using \Drupal::MAJOR_VERSION (see πŸ“Œ Add \Drupal::getMajorVersion() Needs work ) not always printing '8.x' in this warning message.

      Also, shouldn't this message all be wrapped in t()?

    2. core/lib/Drupal/Core/Extension/Dependency.php:      $this->constraint = new Constraint($this->constraintString, \Drupal::CORE_COMPATIBILITY);
      

      This one is more tricky to undo.

    3. core/lib/Drupal/Core/Extension/ModuleDependencyMessageTrait.php:      $version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version'] ?? '');
      

      Here we're using it to conditionally strip off any '8.x-' from a contrib module's version string. Perhaps we don't need a constant for this and can hard-code it in here.

    4. core/lib/Drupal/Component/Version/Constraint.php:   *   Normally this is set to \Drupal::CORE_COMPATIBILITY by the caller.
      

      This is the bulk of where we need to figure out what we want.

    5. core/lib/Drupal.php:  const CORE_COMPATIBILITY = '8.x';
      

      To be removed. 🀞

    6. core/modules/system/system.install:        $version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $required_file->info['version'] ?? '');
      

      Same story as ModuleDependencyMessageTrait... only using it to optionally strip '8.x-' from contrib versions.

      Perhaps we want to move some of this stripping logic into core/lib/Drupal/Component/Version somewhere so we can put the hard-coded weirdness in one spot and re-use it anywhere we're converting contrib bespoke version strings for comparisons.

      Or maybe core/lib/Drupal/Core/Extension/ExtensionVersion.php would be better for this... In fact, it's already got a CORE_PREFIX const in there.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Adding a related issue for schema version.

Production build 0.69.0 2024