Drupal 8.7.7 expected later this week is the first Drupal release to support extensions compatible with multiple major versions of Drupal. This is huge!
Drupal 9 is planned for June 3, 2020 and we are aiming to make the transition as smooth as possible. In fact we build Drupal 9 in Drupal 8 with API deprecations and optional support for new dependencies (Symfony 4.4 is getting very close, while Drupal 8.7.0 was already Twig 2 compatible). Extensions following these deprecations and making sure they are compatible with the updated dependencies could have codebases that are both compatible with Drupal 8 and 9 at the same time, meaning less support burden and earlier Drupal 9 compatibility. In March 48% of contributed projects on Drupal.org were already "Drupal 9 compatible" (as we could detect at the time), and that increased 54% by July (highfive!). These projects will now have one more thing to do, a one line
info.yml file addition, to allow their existing codebase to also run on Drupal 9.
✋Drupal contrib maintainers, thank you! You are already contributing a lot to a successful Drupal 9. Projects that are "compatible with Drupal 9" (as much as we know now) are up to 54% from 48% since March. Deprecated API use is decreasing overall.
You are awesome, keep it up! pic.twitter.com/mHpw4ET0P4
— Gábor Hojtsy (@gaborhojtsy) August 2, 2019
The core: 8.x key did not cut it anymore
Drupal 8 looks at extension
.info.yml files and checks for the
core: 8.x key to check if the extension can be used with Drupal 8. Unfortunately this was not adequate already due to API additions in Drupal 8 minor releases. You could not specify an extension was only compatible with Drupal 8.4+. People devised clever tricks with dependency on certain versions of the system module, but that was still limiting due to inability to depend on specific patch releases. In case your extension depended on a bugfix being present, you cannot set a dependency on Drupal 8.4.1+ in any way.
Introducing the core_version_requirement key
While solving this issue it became apparent that solving it with the existing
core: 8.x key is going to cause backwards compatibility problems with existing Drupal 8 sites. The format of the value could not be changed without causing issues, so a new
core_version_requirement key was introduced. This now allows to depend on major and minor versions of core as well as specify multiple version requirements even between multiple minor Drupal versions. For example if you would need a bugfix that is to be included in both Drupal 8.7.23 and 8.8.3 (imaginary future versions) but you wouldn't care for the minor version, then you would use the following, making your module incompatible with versions before the particular bugfix you need on both minor branches, as well as incompatible with all older Drupal 8 branches:
name: My Module
core_version_requirement: ~8.7.23 || ~8.8.3
Such precision was never possible before!
The new feature is made available in 8.7.7 to help prepare for Drupal 9, as this makes it possible to also declare Drupal 9 compatibility with the existing codebase you already have. Drupal 8.7.x will get security support up until the planned release of Drupal 9 on June 3, 2020. For extensions that only support Drupal 8.7.7 and later you can now exclusively use the
core_version_requirement key. If the extension is also Drupal 9 compatible:
name: My Module
core_version_requirement: ^8.7.7 || ^9
For extensions that also support older versions, you should keep the
core: key as well. The
core_version_requirement key will be ignored by older Drupal versions, and new versions will validate that you specified non-conflicting requirements in the two keys (with regards to Drupal 8 support) so for extensions supporting older core versions,
core_version_requirement also needs to be permissive, but could also allow compatibility with Drupal 9 too:
name: My Module
core_version_requirement: ^8 || ^9
Read more about this change in the change notice. There is also work ongoing to support dependency metadata from
composer.json to drive Drupal's dependency resolution as well. That will coexist with this simpler approach and will provide a more composer-native solution for those who already adopted composer for their extensions. In the meantime at least
core_version_requirement will limit what Drupal would install while
composer.json requirements will limit what composer will download. Because both Composer and Drupal use the term install, but those don't mean the same thing, here is a comparison chart:
|core: 8.x||system module dependency||core_version_requirement||composer.json dependencies|
|Can be used from||Drupal 8.0.0+||Drupal 8.0.0+||Drupal 8.7.7+||Drupal 8.0.0+|
|Allows minor version precision||No||Yes||Yes||Yes|
|Allows patch version precision||No||No||Yes||Yes|
|Allows multiple constraints||No||No||Yes||Yes|
|Limits composer install (download)||No||No||No||Yes|
|Limits Drupal 8 install||Yes||Yes||Yes||No, unless explicit support is added.|
|Allows Drupal 8 and 9 install with same codebase||No||No||Yes||No, unless explicit support is added.|
What happens to Drupal.org project version numbers then?
8.x-1.3 version of an extension on drupal.org may only be compatible with a subset of core, but that was already the case earlier. Now an
8.x-1.3 version of an extension on drupal.org may also be compatible with Drupal 9. How will this work? Drupal's composer integration already ignores the 8.x prefix from version numbers and only cares about the project specific version. Drupal core already only installs extensions where the core compatibility requirements are met regardless of which version number was the package you used to download (8.x modules may be only compatible with 8.4+ already). So the ultimate plan is to do away with the 8.x prefix in extension numbers entirely on drupal.org and support semantic versions for contributed extensions instead. In the short term, the Drupal.org project browser also needs to be updated to take the dependency metadata and use that to power compatibility filters, instead of merely using the version number prefix.
Made a start changing contrib info.yml
Cool. I guess then that adding the suggested line to the ifo.yml is okay if drupal-check passes with "[OK] No errors".
Make the module Drupal 9 compatible [#3087908] | Drupal.org
Add new comment