3

I sometimes need to fix a bug in CiviCRM before that bug is fixed in the latest version of CiviCRM. With non-composer installations, I patch my dev site, commit my changes to git, and push them to a repo, then deploy to test/live sites.

Using composer, CiviCRM isn't in my git repo. What's a reasonable way to manage patches so they a) persist across upgrades, b) can be managed in git?

Alternately: I'd like to test a patch that someone thinks will fix a bug in my CiviCRM installation. How can I do that?

1 Answer 1

3

Drupal 8/CiviCRM has the composer-patches package already installed. So you can add a section to the "extra" element in composer.json called "patches", and list out the patch with a title and a URL (or path) to a .diff file. Here's an example where I add four patches to standard CiviCRM:

diff --git a/composer.json b/composer.json
index 453ff74..5827a69 100644
--- a/composer.json
+++ b/composer.json
@@ -68,6 +68,14 @@
         ]
     },
     "extra": {
+        "patches": {
+          "civicrm/civicrm-core": {
+            "core#609, PR 13390.": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13390.diff",
+            "core#580, PR 13373.": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13373.diff",
+            "membership#9, PR#13553 (membership renewal notification fix)": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13553.diff",
+            "reporting#8, PR 13653 (thank-you dates on contribution reports)": "https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/13653.diff"
+          }
+        },
         "patchLevel": {
             "drupal/core": "-p2"
         },

Note: If you don't use the excellent roundearth/civicrm-composer-plugin but instead use the full manual process to update CiviCRM, you'll need to perform the update steps every time you run composer install with patches.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.