Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing package for re-install and re-patch does not trigger if patches definition is empty (1.7.3) #525

Closed
5 tasks done
GamesmenJordan opened this issue Sep 11, 2023 · 1 comment
Labels
bug Inconsistencies or issues which will cause a problem for users or implementors.

Comments

@GamesmenJordan
Copy link

GamesmenJordan commented Sep 11, 2023

Verification

  • I have updated Composer to the most recent stable release (composer self-update)
  • I have updated Composer Patches to the most recent stable release (composer update cweagans/composer-patches)
  • I am using one of the supported PHP versions (8.0+)
  • I have searched existing issues and discussions for my problem.
  • My problem is not addressed in the troubleshooting guide.

What were you trying to do (and why)?

This is using composer-patches 1.7.3

Removing and re-installing patched modules does not behave correctly when no patches are provided in the composer.json or external patches JSON file.

For example, assuming the following starting state, the below patches have been applied:

{
    "patches": {
        "acme/module-1": {
            "mock-patch-1": "mock-patch-1.patch"
        },
        "acme/module-2": {
            "mock-patch-2": "mock-patch-2.patch"
        }
    }
}

If the user wants to remove both mock-patch-1 and mock-patch-2, and do so by modifying the JSON to the following:

{
    "patches": {}
}

Then running composer install, the previously applied patches would not be removed and the output would be as follows:

Gathering patches from patch file.
No patches supplied.

This differs from expected behavior, for example if we were instead removing only mock-patch-2 the following JSON could be provided:

{
    "patches": {
        "acme/module-1": {
            "mock-patch-1": "mock-patch-1.patch"
        }
    }
}

Running composer install now would re-install acme/module-2 and remove mock-patch-2, and the output would be as follows:

Gathering patches from patch file.
Removing package acme/module-2 so that it can be re-installed and re-patched.
  - Removing acme/module-2 (1.0.0)

The expectation is this same process would be applied to an empty patches definition too. I believe, but haven't verified that this did used to be the case.

I have worked around this issue temporarily by providing fake empty patch in my patches JSON that targets a non-existent module which appears to have the desired behavior.

What happened? What did you expect to happen?

Expected composer install to re-install previously patched modules, restoring them to the un-patched state.

composer install returned "no patches supplied" but did not re-install modules that were previously patched. Previously applied patches remained in place.

@GamesmenJordan GamesmenJordan added the bug Inconsistencies or issues which will cause a problem for users or implementors. label Sep 11, 2023
dotdash added a commit to dotdash/composer-patches that referenced this issue Jan 3, 2024
Currently, if there are no patches provided, we assume that there's
nothing to be done, but that's wrong in case that any installed package
has patches applied, as they need to be re-installed without the
patches now. So the early return needs to be removed.

Fixes cweagans#525
@cweagans
Copy link
Owner

Thanks for your contribution! I am no longer maintaining the 1.x branch. Because of how widely used it is and how little test coverage of that branch there is, I won't be making any more changes to the 1.x branch. Please upgrade to 2.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Inconsistencies or issues which will cause a problem for users or implementors.
Projects
None yet
Development

No branches or pull requests

2 participants