Très Bien Blog: composer drupal-patch-check

Thanks for reading so far. In order to improve the tool I need more examples of real and vetted upgrades I have a handful of examples to use myself but I would need a bit more examples. I need people to supply me with the –dry-run data for the site before an upgrade and after the upgrade so they can be compared and build-in some of the special Drupal sauce in the service that can benefit everyone.
{ "extra": { "drupal-patch-check": { "private-paths": true } } }

Conceptually there is no need to have the plugin send data out, it could be all resolved locally. It’s not going to take a second or two though. It would need some pretty extensive processing and guards to make sure it’s all safe and correct. It is much easier and a few orders of magnitude faster since all the heavy data is already available at hand on my end. For a few years now I’ve built an index of a lot of metadata about Drupal core and contrib, turning that data into a useful service seemed easy enough. 

What is it?

drupal/core 10.2.4 → 11.4.6 5 conflicts, 10 applies
#1 ! conflicts Fix Drupal Views filters boolean-no-value-2862828.patch
core/modules/views/src/Plugin/views/filter/BooleanOperator.php:2: patch failed
core/modules/views/src/Plugin/views/filter/BooleanOperator.php:108: patch failed
core/modules/views/src/Plugin/views/filter/BooleanOperator.php:149: patch failed
(…)

drupal/yoast_seo 2.0.0-alpha10 → 2.2.0 1 conflicts, 1 merged
#1 ✓ merged Uncaught DOMException: Failed to execute 'rem… 3394487-failed-to-execute-remov…
#2 ! conflicts Metatags depending on URL cause errors for un… yoast_seo-3110455-22.patch
src/EntityAnalyser.php:211: patch failed

drupal/search_api_solr_multilingual 3.1.0 1 unknown
#1 ? unknown Drupal 10 compatibility Drupal-10-Compatibility-3370449…
drupal/search_api_solr_multilingual has no release for 11.4.6: the package blocks the upgrade, so its patches cannot be judged

drupal/menu_item_extras 2.19.0 1 unknown
! 3.1.2 supports 11.4.6; the site requires ^2.19. Widen it to ^3.1.
#1 ? unknown Custom fix for client menu_item__extras_client_fix_1.…
3.1.2 supports 11.4.6; the site requires ^2.19. Widen it to ^3.1.

A composer plugin created to make it easy for humans to upgrade their patched Drupal websites.

Starting the patch clean-up

Looks bad, great news:
There are various situation your patch can be in. Starting with the easy ones. 

Summary

drupal/core 11.2.5 4 conflicts, 11 applies
#1 ! conflicts Fix Drupal Views filters boolean-no-value-2862828.patch
core/modules/views/src/Plugin/views/filter/BooleanOperator.php:2: patch failed
core/modules/views/src/Plugin/views/filter/BooleanOperator.php:108: patch failed
core/modules/views/src/Plugin/views/filter/BooleanOperator.php:149: patch failed
#2 · applies Error after saving node drupal 8.7 issue ignore_width_height_on_untransl…
judged after #1 applied in part
(…)
#7 · applies Argument 1 passed 3243387-argument-1-passed-8.pat…
judged with only the part of #1 that applied
#8 ! conflicts TIC-316: Patched parent links (https://www.dr… 3110371-56.patch
core/modules/menu_link_content/src/Form/MenuLinkContentForm.php:92: patch failed
judged after #1 applied in part
(…)
#15 · applies MenuTreeStorage shouldn't invalidate cache ta… 10023.diff
judged after #1 applied in part

$ composer drupal-patch-check

// or the cuter alternative
$ composer drupatch:check

If you ever wanted to know if you still needed that patch after an update, or if your custom patch would still apply to the new version of the module, or if your 15 levels patch tower still applies after the update, this is the tool for you. Install the composer plugin and get started using the remote API.
Not needed anymore:
The API in turns respond with a rich set of data we’re going to explore on a real life composer.json I had to clean up earlier this year by hand.
If you do not want to have the patch path submitted as part of using this tool, you can obfuscate private paths with this in your composer.json:
re-rolled:
patches/core/boolean-no-value-2862828.patch (verified against the release)
the merge kept both additions in 2 regions, check it:
core/modules/views/src/Plugin/views/filter/BooleanOperator.php:194
core/modules/views/src/Plugin/views/filter/BooleanOperator.php:356
patches/allowed_languages/access-denied-page-builder.patch (verified against the release)

Drupal Patch Check: 51 patches against the releases this site installs

simplesamlphp/simplesamlphp 1 patch skipped (not a drupal.org project)
acquia/cohesion 8.2.1 6 patches skipped (not a drupal.org project)

The only difference with the command earlier is that we have a couple of patches dropped: 

Fixing problems

already in the release, drop it:
drupal/geoip: Automated Drupal 10 compatibility fixes
https://www.drupal.org/files/issues/2023-06-16/gepop.3.0.x-update-to-d10.patch

The initial composer.json was broken, a composer install that would not install, and when it finally did patches would barely apply. First step in that situation once the composer install actually finishes:
Let’s see how much of the remaining 16 patches can we figure out automatically
Clean-up is done, our Drupal 10 version is clean, no patch problems. To go from there to Drupal 11 we can run the drupatch command with a target version:
re-rolled with conflicts:
patches/acquia_dam/acquia_dam_versioning_cron_timestamp_fix.conflict.patch (1 region to decide)
src/Cron.php region 0
patches/addtoany/add_SRI_to_JS_file.conflict.patch (1 region to decide)
addtoany.libraries.yml region 0
patches/diff/3359192-display-current-revision-11.conflict.patch (3 regions to decide)
src/Form/RevisionOverviewForm.php region 0
src/Form/RevisionOverviewForm.php region 1
src/Form/RevisionOverviewForm.php region 2
patches/moderated_content_bulk_publish/fix_publish_latest_revision.conflict.patch (1 region to decide)
src/AdminModeratedContent.php region 0
the merge kept both additions in 1 region, check it:
src/AdminModeratedContent.php:258

The composer plugin will help with patches on public drupal.org modules. It doesn’t check or even see the private or custom modules used on your website. This works by calling api.tresbien.tech/v1/composer/scan with a filtered version of your composer.json, composer.lock files as well as the contents of all the associated patches, only for public drupal.org modules. The endpoint is fully controlled by myself, a Drupal core committer, and the data processed will be used to inform how we can prioritize issues for example. There is an option to obfuscate patch paths to avoid disclosing ticket numbers and such. 
$ composer drupatch:check --target=11.4.6

not re-rolled:
it is declared as a URL, so there is no file to replace
https://git.drupalcode.org/project/drupal/-/merge_requests/4098.diff drupal/core: Warning: Undefined array key "#access" in language_form_alter()
https://www.drupal.org/files/issues/2024-01-11/3110371-56.patch drupal/core: TIC-316: Patched parent links (https://www.drupal.org/node/3250632)
cannot re-roll: no release takes this patch, and it does not say which one it was made from; remake it with git diff or re-roll it by hand
patches/core/fix-content-language-expansion-logic.patch drupal/core: Fix content language expansion logic https://www.drupal.org/project/drupal/issues/3414415
patches/acquia_dam/set-placeholder-images.patch drupal/acquia_dam: Set placeholder image if DAM is not responding
patches/acquia_dam/TIC-1341_Fix_SVG_dam_rendering_with_no_width_height.patch drupal/acquia_dam: Fix SVG width height error
patches/acquia_dam/TAC-1415___set_dam_assets_cache_to_1_month.patch drupal/acquia_dam: Set DAM assets cache to 1 month
patches/acquia_dam/SVG_as_Acquia_DAM__Image.patch drupal/acquia_dam: SVG_as_Acquia_DAM__Image
patches/simple_sitemap/TAC-1421___remove_translation_set.patch drupal/simple_sitemap: Remove translation set
error: repository lacks the necessary blob to perform 3-way merge.
patches/tmgmt/tic_648_metatags_tokens_and_fix.patch drupal/tmgmt: TIC-648: Fixed metatag tmgmt + filter tokens

Footer

Reroll please:
drupal/geoip dev-3.x 1 conflicts
#1 ! conflicts Automated Drupal 10 compatibility fixes gepop.3.0.x-update-to-d10.patch
geoip.info.yml:1: patch failed
tests/src/Kernel/GeoLocatorPluginTest.php:31: already in the release, not needed
tests/src/Kernel/RequirementsTest.php:19: already in the release, not needed
tests/src/Kernel/RequirementsTest.php:31: already in the release, not needed
tests/src/Unit/CdnGeoLocatorTest.php:2: patch failed
tests/src/Unit/CdnGeoLocatorTest.php:17: patch failed
tests/src/Unit/GeoLocationTest.php:2: patch failed
run composer drupatch:reroll to see if the release has the rest

After some work I got to a clean composer install state. The site is still outdated, new core and contrib releases went out, what happens when we try to update the site? which patches will break? 
Conflits:

Updating to major version

Everything is fine, or fine enough:
Rerolled automatically:
$ composer require --dev tresbientech/drupal-patch-check

$ composer drupatch:reroll

Big picture

Can’t reroll:
The patch tower™:
$ composer drupatch:check
$ composer drupatch:check --target=latest
$ composer drupatch:reroll --target=latest

drupal/entity_reference_revisions 1.12.0 1 applies
#1 · applies Draft translations should be based on the lat… moderation-translation-err-rc1-…

drupal/permissions_by_term 3.1.40 1 applies
#1 · applies Extend permissions by edit and create permiss… access_for_view_nodes.patch
context drifted, needed: git apply -p1 -C1 --ignore-whitespace --recount

patches: 35 applies, 16 conflicts
composer applied these patches at install, so the files on disk show them

Next: composer drupatch:reroll writes the 16 re-rolls

patches: 27 applies, 24 conflicts, 1 merged, 4 unknown
composer already applied these patches to your files

Next: composer drupatch:reroll --target 11.4.6 writes the 24 re-rolls
composer drupatch:reroll --target 11.4.6 --update drops the shipped entry from composer.json

Drupal Patch Check: 56 patches for a move from core 10.2.4 to 11.4.6

patches: 2 now apply, 21 conflicts left, 4 unknown

already in the release, dropped:
drupal/geoip: Automated Drupal 10 compatibility fixes
https://www.drupal.org/files/issues/2023-06-16/gepop.3.0.x-update-to-d10.patch

Sometimes patches are not well enough structured to get them evaluated, the patches need some work to get the service to be able to do anything with them. There is some guidance about what is wrong with the patches for the service to be able to do something with them.

Similar Posts