Package manager/ Automatic Updates should disallow composer patches by default

Created on 13 September 2024, 8 months ago

Problem/Motivation

Spin-off from Add Alpha level Experimental Package Manager module Needs review .

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

📌 Task
Status

Active

Version

11.0 🔥

Component
Base 

Last updated about 1 hour ago

Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @catch
  • 🇳🇿New Zealand quietone

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

  • 🇬🇧United Kingdom catch

    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.

  • 🇬🇧United Kingdom catch
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
  • 🇬🇧United Kingdom catch

    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 patches applied, 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 📌 Dependencies should be 'unpacked' to the root composer.json and merged/resolved Active - 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.

  • First commit to issue fork.
  • 🇺🇸United States phenaproxima Massachusetts

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

  • Merge request !11903Disallow patches support by default → (Closed) created by phenaproxima
  • Pipeline finished with Failed
    19 days ago
    Total: 402s
    #478493
  • Pipeline finished with Failed
    19 days ago
    Total: 577s
    #478542
  • Pipeline finished with Success
    19 days ago
    Total: 691s
    #478553
  • 🇺🇸United States phenaproxima Massachusetts

    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.

  • 🇺🇸United States phenaproxima Massachusetts
  • 🇺🇸United States tedbow Ithaca, NY, USA

    See MR comment

  • Pipeline finished with Failed
    18 days ago
    Total: 399s
    #479226
  • 🇺🇸United States phenaproxima Massachusetts

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

  • Pipeline finished with Success
    18 days ago
    Total: 320s
    #479241
  • 🇬🇧United Kingdom catch

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

  • 🇺🇸United States phenaproxima Massachusetts

    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.

  • 🇬🇧United Kingdom catch

    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...
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    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...
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    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

Production build 0.71.5 2024