Problem/Motivation

Spin-off from #3346707: Add Alpha level Experimental Package Manager module.

Automatic updates allows sites to run both AU + composer patches at once.

Composer patches is incompatible with actually updating a site automatically, because as soon as a patch is committed upstream, or an upstream change causes a conflict, you need to manually determine the problem with the patch and either replace it with a newer one or remove it - both of which require manually editing JSON.

Additionally, applying patches that include update paths is very high risk and can leave a site in a state where it's not possible to update the database successfully - e.g. if a different update takes hook_update_N().

However, this is not a barrier to using project browser, or some advanced AU use-cases where a developer is prepared to manually intervene every so often and AU is only expected to handle what it can handle.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#7 package_manager_patch.patch4.98 KBiamcorekhan

Issue fork drupal-3474292

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

catch created an issue. See original summary.

quietone’s picture

I agree with not allowing composer patches by default, for the reasons explained in the issue summary.

catch’s picture

Tagging this as a package manager/automatic updates beta blocker, we could potentially move it to a stable blocker later but should at least discuss more before beta.

catch’s picture

Priority: Major » Critical
larowlan’s picture

catch’s picture

This validation is done in ComposerPatchesValidator, currently it checks if composer patches is a root composer dependency, and issues a validation error if it's a dependency anywhere else and not root.

Probably what we'd need here is a settings.php flag to enable that behaviour, defaulting to FALSE, and then only allow composer patches as a root requirement when it's TRUE. This would force people to make an explicit choice to use package_manager with composer patches, rather than potentially doing it by accident/without thinking about the consequences.

My main concern here is that someone installing Drupal CMS (and eventually site templates) via the UI, never gets into a situation where they have to manually edit JSON to update their site. Requiring a settings.php flag would mean that only pre-release versions of site templates could ship with dependencies on composer patches, which is fine for testing, but they would need to be committed upstream before a stable release, and the composer dependency removed, in order to work with automatic updates/project browser.

I'm not sure how this interacts with #3355485: Dependencies should be 'unpacked' to the root composer.json and merged/resolved - e.g. if recipes specify dependencies on composer patches, and those then get unpacked to the root composer.json, will that trigger the validation or not? From reading it, it looks like it prevents that situation from happening. I think if the answer to this is that it's impossible for that to happen and it will produce a validation error, we could move this to a stable rather than beta blocker. As long as the settings.php flag is enough, and we're fine restricting the behaviour beyond what it allows now during beta, the actual code change should be pretty small.

iamcorekhan’s picture

StatusFileSize
new4.98 KB

phenaproxima made their first commit to this issue’s fork.

phenaproxima’s picture

Adjusting credit, since the MR is a slimmed-down version of the patch in #7.

phenaproxima’s picture

Status: Active » Needs review

Seeing as how ComposerPatchesValidatorTest failed until I specifically enabled the setting in that test, I'd hazard to guess that there's probably no additional test coverage needed here. Crediting myself for the MR.

phenaproxima’s picture

Title: Package manager/ Automatic Updates should disallow composer patches by default » Package Manager should disallow cweagans/composer-patches by default
Component: base system » package_manager.module
tedbow’s picture

Status: Needs review » Needs work

See MR comment

phenaproxima’s picture

Status: Needs work » Needs review

I like that a lot better. We don't need to worry about versions, we support both majors in ComposerPatchesValidator.

catch’s picture

That looks simpler, but does it need new test coverage then?

edit: or wait - is the validator test change the test coverage? But if so, can we add an assertion above to show that it's really not allowed, or would that duplicate other test coverage elsewhere?

phenaproxima’s picture

It would duplicate other test coverage. Now the patcher is just treated like any other "untrusted" plugin, which will raise a validation error unless explicitly allowed in configuration.

catch’s picture

Status: Needs review » Reviewed & tested by the community

That was my only question, this is much simpler than the new setting.

  • larowlan committed f2262b72 on 11.x
    Issue #3474292 by phenaproxima, iamcorekhan, catch, tedbow: Package...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 11.x - thanks all

  • larowlan committed 58ed5801 on 11.x
    Revert "Issue #3474292 by phenaproxima, iamcorekhan, catch, tedbow:...

  • larowlan committed bc40a08c on 11.x
    Issue #3474292 by phenaproxima, iamcorekhan, catch, tedbow: Package...

larowlan’s picture

Take 2, committed the right thing this time. Been having grief with gitlab signing me out and looks like the signin button sent me to a previous MR I'd viewed. Still my fault for not doing git show before I pushed. Resolved now

Status: Fixed » Closed (fixed)

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