Support for Drupal 8 ends in a few months, so the push is on to update Drupal modules to be compatible with Drupal 9. There are tools and documentation on porting modules to Drupal 9, but this note addresses one point that has been neglected until now.
One simple but important step in making a module compatible with Drupal 9 is to declare that compatibility by adding a line to the module’s .info.yml
file. For some modules, that is the only step needed.
Once the module has been updated, it’s easy to install it on a Drupal 9 site. But there is a chicken-and-egg problem if some helpful contributor has proposed a change to the module, but the maintainer has not yet adopted it. Perhaps you maintain a Drupal 9 site and want to add that module, or perhaps you are one of the helpful contributors who plans to test the change. Since the module does not declare compatibility with Drupal 9, the usual way of installing the module (and applying the change) does not work.
This seems to be the easiest way to install a module with Drupal 9, if the module is in that in-between stage where the necessary changes have been proposed but not yet adopted. This assumes that you manage Drupal with Composer. Using Composer is the recommended method for Drupal 8/9, and it is required for some modules.
For example, look at the Views URL alias module. There is already an issue to update the module, with the standard issue title: Automated Drupal 9 compatibility fixes. The Project Update Bot opened this issue and proposed changes by uploading a patch. Luckily, a helpful contributor already created a merge request from that patch. This method requires the merge request. The helpful contributor also made further improvements, starting with the changes proposed by the Bot.
https://git.drupalcode.org/issue/views_url_alias-3142138
. The last part of the URL is the link text: views_url_alias-3142138.git checkout -b '3142138-automated-drupal-9' --track views_url_alias-3142138/'3142138-automated-drupal-9'
The part in quotes after git checkout -b
is the branch name.
composer.json
for your Drupal project. Add a section to the top-level repositories key like this: "repositories": [ { "type": "vcs", "url": "https://git.drupalcode.org/issue/views_url_alias-3142138" }, ... ]
For the url
key, use the Issue fork URL.
drupal/PROJECT:dev-BRANCH
. Continuing with the same example, open a shell and run this command:composer require drupal/views_url_alias:dev-3142138-automated-drupal-9
If all goes well, then Composer will update composer.json
and download the module with all of its requirements. Enable the module and see whether it works with Drupal 9.
Remember to close the loop. You are benefiting from all the helpful contributors, and the way to show your appreciation is by posting a comment to the issue. Did it work? Were there any problems? Either way, give details!
Benji is one of the leading Drupal contributors and Fruition's senior Drupal Developer. Benji focuses on writing reliable and maintainable code. This means clear documentation and structure with commits to continuously improve the code base. Benji graduated with an AB in mathematics from Harvard and a Ph.D in mathematics from Princeton.
How Devs Optimize UX For Your Brand Website
Read Article →iOS14 & iOS15 Update: What You Need To Know
Read Article →Fruition Named Top Web Development Company in Denver by Digital.com
Read Article →