Drupal 8 Tip: How To Patch A Module Via Composer

In my case I was using the Entity Auto Term module, which issued a patch fixing a known issue. The patch i’m trying to apply is https://www.drupal.org/files/issues/2018-09-28/no-duplicate-terms-2945343-5.patch and part of it looks like this:

To apply it, you have to edit your composer.json located at your website root, pictured here via Filezilla FTP:

I right click view/edit to edit it in Notepad++ here:

I will need to add the red part below. You will most likely have the green part already present, so just edit the red “patches” section to fit your needs.

"extra": {

"installer-paths": {


"web/core": ["type:drupal-core"],


"web/libraries/{$name}": ["type:drupal-library"],


"web/modules/contrib/{$name}": ["type:drupal-module"],


"web/profiles/contrib/{$name}": ["type:drupal-profile"],


"web/themes/contrib/{$name}": ["type:drupal-theme"],


"drush/contrib/{$name}": ["type:drupal-drush"]


},

"patches": {

"drupal/eat": {


"Drupal EAT fix duplicate terms": "https://www.drupal.org/files/issues/2018-09-28/no-duplicate-terms-2945343-5.patch"


}


}


}

Next run Composer Update, and the output should look like this:

That’s it you should be all set.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.