项目作者: WidgetsBurritos

项目描述 :
Checks for risky hook_update_N() references in composer patches.
高级语言: PHP
项目地址: git://github.com/WidgetsBurritos/drupal-patch-checker.git
创建时间: 2018-12-05T03:45:08Z
项目社区:https://github.com/WidgetsBurritos/drupal-patch-checker

开源协议:GNU General Public License v3.0

下载


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. 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:

  1. composer require --dev widgetsburritos/drupal-patch-checker

Then add the following to your composer.json file:

  1. "scripts": {
  2. "check:patch": [
  3. "WidgetsBurritos\\DrupalPatchChecker\\DrupalPatchChecker::checkComposerFile"
  4. ],
  5. }

Checking Patches Manually

You can check your patches manually by running:
composer run check:patch

This will produce a result similar to this:

  1. $ composer run check:patch
  2. > WidgetsBurritos\DrupalPatchChecker\DrupalPatchChecker::checkComposerFile
  3. Script WidgetsBurritos\DrupalPatchChecker\DrupalPatchChecker::checkComposerFile handling the check:patch event terminated with an exception
  4. [Exception]
  5. 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:

  1. "scripts": {
  2. "check:patch": [
  3. "WidgetsBurritos\\DrupalPatchChecker\\DrupalPatchChecker::checkComposerFile"
  4. ],
  5. "post-install-cmd": [
  6. "composer run check:patch"
  7. ],
  8. "post-update-cmd": [
  9. "composer run check:patch"
  10. ],
  11. }

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.