Lenient Patches in Drupal with Composer

Lenient Patches in Drupal with Composer

a few weeks* ago I came across an interesting post by Michael Anello in which he mentioned the Lenient Composer Plugin by Matt Glaman . I thought it was pretty cool -- definitively something I've already needed -- but apart from leaving a funny little comment, I was waiting for an opportunity to use it.

and now that time has come. *dramatic lightning

I've tested it and it's really easy. follow along:

$ cd ~/projects/drupal_11_project
$ ddev composer require 'drupal/convert_bundles:^2.0@beta'        

the above commands will throw an error, because the Convert Bundles module is still not ready for D11, at least not when I'm writing this anyway. but surely we won't hold it against its creator, right? instead, let's try that plugin:

$ ddev composer require mglaman/composer-drupal-lenient
$ ddev composer require cweagans/composer-patches        

we're also using the excellent Composer Patches by Cameron Eagans , which will allow the module to be patched and properly used without conflicts, even before a D11 compatible version was officially released.

next, run:

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

then add the patches section in your codebase's composer.json file:

"patches": {
    "drupal/convert_bundles": {
        "Automated Drupal 11 compatibility fixes for convert_bundles": "https://www.drupal.org/files/issues/2024-03-16/convert_bundles.2.0.0-beta4.rector.patch"
    }
}        

and patch it:

$ ddev composer require 'drupal/convert_bundles:^2.0.0-beta4'
$ ddev composer update drupal/convert_bundles        

before patching the module's info.yml file looked like that:

core_version_requirement: ^9 || ^10        

and now it looks like this:

core_version_requirement: ^9 || ^10 || ^11        

so there you go!

if you've found this guide useful, I'm glad. but if you've found an error, please let me know!


__

*three, to be precise.

Thomas Kaisuka

Web Developer | Drupal | Data Science | Machine Learning

1 个月

Brilliant compilation. Tried it on my Drupall 11 site and it works just fine.

回复
Michael Anello

Co-owner at DrupalEasy

1 个月

Thanks for the mention! Glad I could help.

要查看或添加评论,请登录

Luciano Cossich Sales的更多文章

社区洞察

其他会员也浏览了