Hi,

There seems to be an issue with patches not applying and composer update --with-dependencies stops if the module to be patched has already been updated with the patch in question.

So far I have encountered it on ds module and on slick. Only way to circumvent this has been to edit composer.json and change "composer-exit-on-patch-failure": true to false and re-run composer update --with-dependencies.

Not sure if this is safe however as there could be other modules that need patching not related to this issue and cause more problems if allowed to update.

regards,

Comments

mellowtothemax created an issue. See original summary.

mohammed j. razem’s picture

Category: Bug report » Support request
Status: Active » Fixed

Hi mellowtothemax,

This issue has been annoying us for quite some time, as Varbase and other Drupal distros rely on patches to work well.
The patches package we're using is called "cweagans/composer-patches". This package handles the patching mechanism.
If we set "composer-exit-on-patch-failure" to false, this could break the site's installation and some functionalities since some patches are crucial for the functioning of Varbase.

Therefore, we have thought of a better way to handle patching (it's now implemented in Varbase 8.6.3 and above), therefore, you'll need to update your Varbase version to make use of this patching mechanism.

The flow goes as this:

Patching Scenarios:

You run composer update, new versions of modules or core are downloaded. If patches for those modules are included, there are 3 possible scenarios:

  1. Best case: Patch has not been included, and new version did not break the patch.
    • Patch is still needed? Yes
    • Patch will apply? Yes
    • Manual action needed? No
  2. Average case: Patch has been included in the new version.
    • Patch is still needed? No
    • Patch will apply? No
    • Manual action needed? Yes. Remove the patch from composer.json
  3. Worst case: Patch has not been included, and new version did break the patch.
    • Patch is still needed? Yes
    • Patch will apply? No
    • Manual action needed? Yes. Manually re-roll the patch, handle conflict, and fix it yourself

The New "vardot/composer-patches" and How It Will Handle Those Scenarios:

Based on these scenarios, we have forked the "cweagans/composer-patches" package, and added an Event Dispatcher on patch failure. The Event Dispatcher will dispatch an Event that will prompt you to perform an action depending on the scenarios above. Thus:

  1. Best case: Patch has not been included, and new version did not break the patch.
    • Nothing will happen.
  2. Average case: Patch has been included in the new version.
    • The Varbase Updater will detect that the patch has been applied and ask you if you want to remove it from your composer.json
  3. Worst case: Patch has not been included, and new version did break the patch.
    • The Varbase Updater will log failed patches to a file named failed-patches.txt. You can review it and try to handle those patches yourself.

How To Use "vardot/composer-patches":

If you're using Varbase 8.6.3 or greater, just run composer update and it will work.

If you're using Varbase 8.6.2 or older, you can update to the most recent version of Varbase 8.6.x and make use of this functionality. Or run the following commands:

  1. Add Vardot's composer-patches repository to use our forked package instead of the cweagans's.
    composer config repositories.composer-patches vcs https://github.com/vardot/composer-patches
  2. Run composer update to get the new package.
  3. Run composer update again to update your packages and start applying the new patching mechanism.

We hope this will make updating and handling patches as easy as possible for developers.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.