Lissy
Lissy

Reputation: 71

How to install patched modules in fresh Drupal 10 Installation?

I have a fresh Drupal 10 Installation und would like to install some modules with more ore less simple patches. I tried it in different ways and get allways the same errors with composer require.

This are my steps:

  1. manual changed files for exampe in superfish for this patch: https://www.drupal.org/files/issues/2022-08-01/superfish-%233.patch and manually put the module in module/contrib folder. Than I tried composer require drupal/superfish:~1.4 with different versions and with and without parameter -W.

  2. I wrote patch in composer.json and tried composer install. There comes the message nothing to install or update. I used also composer update --lock

  3. I downloaded last dev-Version and patch and tried with git apply.

The result with composer require is more ore less the same error like this:

Problem 1 - drupal/block_content_permissions[1.0.0, ..., 1.8.0] require drupal/core ^8 -> found drupal/core[8.0.0, ..., 8.9.20] but these were not loaded, likely because it conflicts with another require. - drupal/block_content_permissions[1.9.0, ..., 1.10.0] require drupal/core ^8 || ^9 -> found drupal/core[8.0.0, ..., 8.9.20, 9.0.0, ..., 9.5.0] but these were not loaded, likely because it conflicts with another require. - Root composer.json requires drupal/block_content_permissions * -> satisfiable by drupal/block_content_permissions[1.0.0, ..., 1.10.0].

You can also try re-running composer require with an explicit version constraint, e.g. "composer require drupal/block_content_permissions:*" to figure out if any version is installable, or "composer require drupal/block_content_permissions:^2.1" if you know which you need.

If I enable the patched modules manualy in backend, they work normaly. But they are not under composer controll.

How to do in the right way?

Upvotes: 2

Views: 1488

Answers (2)

Susobhan Das
Susobhan Das

Reputation: 1164

To use Drupal lenient Patch.

-- First install lenient patch in composer

$ composer require mglaman/composer-drupal-lenient

Objective of lenient patch - is to make available the Drupal modules overcome the Drupal core version requirement.

But you need to add the (Drupal 10 ready) Drupal.org patch link in composer.json

Example : userpoints module do not have drupal 10 release yet. So, to add Drupal 10 compatible patch.


$ composer config --merge --json extra.drupal-lenient.allowed-list '["drupal/userpoints"]'
$ composer require 'drupal/userpoints:^2.0@beta'

-- Add working latest #8 patch in composer.json, only the patches part - or you can compare with your composer.json file

{
  "require": {
      "mglaman/composer-drupal-lenient": "^1.0",
      "drupal/userpoints": "^2.0@beta"
  },
  "extra": {
      "patches": {
          "drupal/userpoints": {
              "deprecated drupal 10 readiness": "https://www.drupal.org/files/issues/2022-10-09/userpoints-n3314326-8.patch"
          }
      },
      "drupal-lenient": {
          "allowed-list": ["drupal/userpoints"]
      }
  }
}

Now composer update will delete and re-patch the module. In the above userpoints module used, there are so many modules having Drupal-9 but no Drupal 10 release.

So, you can even add issue queue in Drupal.org, and put your own patch-file link in composer.json preceded by the leninent composer method to allow particular module.

For details on Lenient Patch

  1. Using Drupal's Lenient Composer Endpoint
  2. Github mglaman/composer-drupal-lenient page

Upvotes: 1

rocketeerbkw
rocketeerbkw

Reputation: 323

Drupal.org has a documented process for allowing a lenient composer install.

For Drupal 10:

Try the Lenient Composer Plugin

The lenient composer plugin lets you specify an allowlist of packages where you are willing to break the version constraint, using a command like:

composer config --merge --json extra.drupal-lenient.allowed-list '["drupal/token"]'

Together with the Composer Patches Plugin, this allows you to install any Drupal extension, even if the version constraint hasn't been officially updated yet. Of course the code may still need to be patched for deprecations.

Upvotes: 4

Related Questions