Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/widgetsburritos/drupal-patch-checker
Checks for risky hook_update_N() references in composer patches.
https://github.com/widgetsburritos/drupal-patch-checker
checker composer-plugin drupal drupal-8 patching
Last synced: about 2 months ago
JSON representation
Checks for risky hook_update_N() references in composer patches.
- Host: GitHub
- URL: https://github.com/widgetsburritos/drupal-patch-checker
- Owner: WidgetsBurritos
- License: gpl-3.0
- Created: 2018-12-05T03:45:08.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-09-29T21:02:44.000Z (over 1 year ago)
- Last Synced: 2024-12-17T17:16:33.896Z (about 2 months ago)
- Topics: checker, composer-plugin, drupal, drupal-8, patching
- Language: PHP
- Homepage: https://www.widgetsandburritos.com/posts/2018-12-07/patching-production-drupal-sites-hook-update-n-risky
- Size: 104 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Drupal Patch Checker
A simple helper script for checking composer dependencies to ensure it's not adding `hook_update_N()` functions via patches.
## Why This Exists
I recently realized that [using patches containing hook_update_N() is risky](https://www.widgetsandburritos.com/posts/2018-12-07/patching-production-drupal-sites-hook-update-n-risky). Long story short, it could potentially create conflicts with other module updates, meaning some update hooks may never run at all. This can have some negative effects down the road. This script helps preempt those issues.
## First Time Setup
Install this package as a dev dependency:```bash
composer require --dev widgetsburritos/drupal-patch-checker
```Then add the following to your `composer.json` file:
```json
"scripts": {
"check:patch": [
"WidgetsBurritos\\DrupalPatchChecker\\DrupalPatchChecker::checkComposerFile"
],
}
```## Checking Patches Manually
You can check your patches manually by running:
```composer run check:patch```This will produce a result similar to this:
```bash
$ composer run check:patch
> WidgetsBurritos\DrupalPatchChecker\DrupalPatchChecker::checkComposerFile
Script WidgetsBurritos\DrupalPatchChecker\DrupalPatchChecker::checkComposerFile handling the check:patch event terminated with an exception[Exception]
patches/language_hierarchy/language_hierarchy-limit_views_results-2825851-14.patch contains hook_update_N() on Line 50.
```## Checking Patches Automatically on Package Install/Update
If you want to prevent patches from getting installed altogether update your `composer.json` file accordingly:
```json
"scripts": {
"check:patch": [
"WidgetsBurritos\\DrupalPatchChecker\\DrupalPatchChecker::checkComposerFile"
],
"post-install-cmd": [
"composer run check:patch"
],
"post-update-cmd": [
"composer run check:patch"
],
}
```Then the next time you run `composer install` or `composer update` if your project contains a patch with `hook_update_N()` it will throw an exception.