HomeDecorative ElementBlogDecorative ElementApplications
Upgrade & Test Drupal 8 Modules for Latest Drupal 9 Compatibility
Uncover insights to seamlessly transition Drupal 8 modules to Drupal 9. Achieve module compatibility and successful implementation with Composer.

Developer Tips: Testing A Drupal 8 Module On Drupal 9

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 onporting 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.

How To Install A Module With A Merge Request

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.

  1. Scroll down the page to find the Issue fork section, as shown in this screenshot:

  2. Copy the URL of the issue fork: for this issue, the URL is https://git.drupalcode.org/issue/views_url_alias-3142138. The last part of the URL is the link text: views_url_alias-3142138.

  3. While you are here, you might want to open About issue forks in another browser tab, so that you can read it later.

  4. You will also need the branch name. To get this, trigger the link labeled “Show commands”. In the third text area, you should see something like this:
    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.

  5. Now that you have the Issue fork URL and the branch name, edit 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.

6.. The last step is to require the correct branch of the project, in the form 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!

Table of Contents
    Table of Contents+