0

I'm trying to make a patch for a contrib module so that it will use a new version of one it's "required" vendor libraries.

The composer.json is in the module's directory and looks like this:

"require": {
        "wa72/htmlpagedom": "1.3",
        "drupal/pdf_api": "^2.0"
    },

I need "wa72/htmlpagedom:^3" to be installed so I changed the version number in the module's composer.json file

Running composer update drupal/MODULE_NAME does nothing.

If I try "composer require "wa72/htmlpagedom:^3" -w" I get error/problems reports that the module is still locked at the original version (1.3).

I've tried deleting the composer.lock file and clearing Composer cache but nothing that I've tried has allowed me to install the updated version of htmlpagedom.

  Problem 1
    - Root composer.json requires wa72/htmlpagedom ^3, found wa72/htmlpagedom[dev-master, v3.0.0, 3.0.x-dev] but these were not loaded, likely because it conflicts with another require.
  Problem 2
    - drupal/printable is locked to version 2.1.3 and an update of this package was not requested.
    - drupal/printable 2.1.3 requires wa72/htmlpagedom ^1.3 -> found wa72/htmlpagedom[v1.3.0, ..., 1.x-dev] but it conflicts with your root composer.json require (^3).

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Screenshot of composer output:

enter image description here

2
  • Screenshots of output are difficult to deal with. Please past the raw text.
    – cilefen
    Jul 14, 2022 at 15:26
  • 1
    @cilefen - text output has been posted to original post. Jul 14, 2022 at 15:40

1 Answer 1

3

Simple answer: You can't. Composer patching happens after calculating and downloading all dependencies.

2 possible workarounds:

  • Fork the contrib module and require your forked custom module.
  • Require the new version in your root project and alias it as the old version as demanded by the contrib module: composer require wa72/htmlpagedom:X.Y.Z as 1.3

And TBH, none of the above is a good idea :-) Better create a merge request for the contrib module in the official repository and fix it properly.

6
  • So, I'm trying to test the vendor update on my local copy and would like to modify the module so that I can update the vendor file before doing a merge request. However, modifying the module's composer.json file (as detailed above) does not allow for updating the vendor library. Do you know the steps so that I can update my local copy of the module to use htmlpagedom:^3 for local testing? Jul 14, 2022 at 15:17
  • The fundamental problem is that drupal/printable 2.13 requires wa72/htmlpagedom ^1.3, which means the version of drupal/printable is not compatible with wa72/htmlpagedom 2 or 3, and someone has to test drupal/printable for compatibility and perhaps change it to be compatible.
    – cilefen
    Jul 14, 2022 at 15:29
  • 1
    And wa72/htmlpagedom:^3 requires php:^8, which means this won't be a simple merge request, this needs a major version bump.
    – Hudri
    Jul 14, 2022 at 15:34
  • Yes, that's the reason I'm trying to modify the module, so that it will work on our PHP8 install. The module currently works but floods watchdog with deprecated function notices. htmlpagedom v3 resolves this issue so I was hoping to update the Drupal Printable module to use this version of htmlpagedom. Thank you for the link to docs on merge requests, I'm going to digest this shortly. Jul 14, 2022 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.