Skip to content

Resolve #3148726 "Automated drupal 9"

Cumulative Drupal 9 Readiness Patches.

This MR combines all the Drupal 9 compatibility patches from https://www.drupal.org/project/select_registration_roles/issues/3148726#comment-13673528 plus additional patches intended to address PHPCS errors and warnings.

The additional patches include things like standardizing doc blocks, using \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead of t(), and including type hints for method parameters.

It is useful to have an issue fork for Drupal 9 compatibility, rather than simply a patch, because:

In short, you can't use a patch to tell Composer that a Drupal 8 module is compatible with Drupal 9.

Source: https://www.mediacurrent.com/blog/how-fix-catch-22-problem-drupal-9-fixes-composer/

To use this issue fork as a transitional D9-compatible package in your project, modify your composer.json:

For Drupal 8 projects (about to be upgraded):

    "repositories": {
        "drupal/select_registration_roles": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/issue/select_registration_roles-3148726"
        },
        "drupal": {
          "type": "composer",
          "url": "https://packages.drupal.org/8",
          "exclude": ["drupal/select_registration_roles"]
        },

For Drupal 9 projects (after upgrading, but before D9-compatible module is released):

    "repositories": {
        "drupal/entity_activity": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/issue/select_registration_roles-3148726"
        },
        "drupal": {
          "type": "composer",
          "url": "https://packages.drupal.org/9",
          "exclude": ["drupal/select_registration_roles"]
        },

Requiring the patched package from the Issue Fork:

Execute the following command in a terminal:

$ composer require drupal/select_registration_roles:dev-3148726-automated-drupal-9

or manually add the requirement to composer.json:

    "require": {
        "drupal/select_registration_roles": "dev-3148726-automated-drupal-9",

Credit due, mainly, to Benji Fisher via: https://www.drupal.org/project/views_url_alias/issues/3142138#comment-14177409

NOTE: The above code is not yet tested, so I may need to revise the instructions shortly. :)

Closes #3148726

Merge request reports