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

Remove the cweagans/composer-patches patch to prevent whole /web dir might get deleted #474

Closed
Leksat opened this issue Mar 11, 2019 · 9 comments

Comments

@Leksat
Copy link

Leksat commented Mar 11, 2019

Currently there are two ways to lose /web directory completely:

Apply a patch to Drupal core

We have this code:

"patches": {
"cweagans/composer-patches": {
"Call the preserve paths hooks" : "https://github.com/SebCorbin/composer-patches/commit/1cb9bacba51f8bba0c5f3f322c3bb61e4ceae974.patch"
}
},

It tries to solve the issue described in drupal-composer/preserve-paths#10

However, this does not work. Explained here: drupal-composer/preserve-paths#10 (comment)

Moreover, current setup is pretty confusing and it can lead to not nice situations. For example, this could happen:

  • A D7 project was migrated to drupal-composer/drupal-project
  • The patch was applied nicely to cweagans/composer-patches package
  • During deployment, the patch was not applied to the production installation
  • Later, a developer applied a patch to Drupal core locally (and this worked fine because the composer-patches patch was applied on the developer's installation)
  • The /web directory was vanished on production during the deployment

Proposed solution:

  • remove the current patch
  • make a fork of cweagans/composer-patches with the patch applied
  • use the fork in drupal-composer/drupal-project

If composer-exit-on-patch-failure is true, and there is an issue with applying a Drupal core patch

composer-exit-on-patch-failure is not part of the composer.json in the 7.x branch

@jcnventura jcnventura added the D7 label Mar 12, 2019
@jcnventura
Copy link
Collaborator

I'm not sure if a fork of cweagans/composer-patches just to apply this patch is the best solution.

I think that forcing the patching of that package somehow in the post-create-project-cmd step or maybe also in the pre-install-cmd and pre-update-cmd steps, would be a way more maintainable solution.

@jcnventura
Copy link
Collaborator

Also note that composer-exit-on-patch-failure is not part of the composer.json in the 7.x branch.

@Leksat
Copy link
Author

Leksat commented Mar 13, 2019

forcing the patching of that package somehow in the post-create-project-cmd step or maybe also in the pre-install-cmd and pre-update-cmd steps

I know only these ways to patch a package:

  • change "patches" section in composer.json
  • remove and re-add the package

Both are not usable for composer pre/post commands.

Maybe @cweagans know other ways?

@jcnventura
Copy link
Collaborator

Yes, this would not be done the 'normal' way... It would be a direct call for composer-patches to patch itself. It would probably require some custom PHP code, but most likely it should not be too complicated.

The question is whether that code should be on this project or in composer-patches.. It is somewhat a bug in that package that it is unable to apply a patch to itself on the first install.

@jcnventura
Copy link
Collaborator

Just for reference the discussion on this is going on at cweagans/composer-patches#42

@back-2-95
Copy link

We created this for D7 projects: https://github.com/druidfi/mona-plugin

See how it's used in: https://github.com/druidfi/mona/blob/master/composer.json

@leymannx leymannx changed the title D7: it's easy to lose /web directory (together with sites/default/files) It's easy to lose the whole /web directory (together with sites/default/files) Jan 12, 2021
@leymannx leymannx changed the title It's easy to lose the whole /web directory (together with sites/default/files) Remove the cweagans/composer-patches patch to prevent whole /web dir might get deleted Jan 12, 2021
@steinmb
Copy link

steinmb commented Jun 13, 2022

Existing D7 site that 6 months ago was converted to Composer. During composer install --no-dev we lost all files in web directory.

Not sure how we make sure this not happen again and I am not able to re-create this in dev.

  • Composer version 2.2.13
  • PHP 7.1.33
  • Drupal 7.89 => 7.90 core upgrade
        "patches": {
            "cweagans/composer-patches": {
                "Call the preserve paths hooks" : "https://github.com/jcnventura/composer-patches/compare/1.x...jcnventura:fix-preserve-paths.diff"
            }
        },
        "preserve-paths": [
            "web/sites"
        ]

@driskell
Copy link

driskell commented Feb 8, 2023

I reported an issue with meta packages and overlapping preserve paths like this
in drupal-composer/preserve-paths#42 . If the composer patches patch didn’t fix the issue it’s likely this issue instead

@AlexSkrypnyk
Copy link
Collaborator

This pull request/issue has been inactive for over a year and is being closed due to inactivity. If the issue still persists or the contribution is still relevant, please feel free to reopen it or create a new one.

Thank you for your understanding and your contributions to the project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants