Unable to disable any hooks

Created on 6 September 2024, 3 months ago

Not sure if I am missing something, but I have had to do some jiggery-pokery to get this module to work. These are the steps I have taken to get a result (i.e. skipping the sos_mailchimp_ENTITY_TYPE_update() hook):

  1. Added the config to settings.php:
    $config['migrate_boost.settings'] = [
      'modules' => [
        'sos_mailchimp',
      ],
      'hooks' => [
        'sos_subscription_update' => [
          'sos_mailchimp',
        ],
      ],
    ];

    I realise these settings overlap - I added 'hooks' when nothing was happening so I wanted to try both methods.

  2. Commented out the initial if/return test on static::$alterActive in MigrateBoost.php/alter() as it is always set to NULL, preventing the function from ever running.
  3. Run the migration via drush:
    ddev drush migrate:boost:reset
    ddev drush migrate:import sos_subscription --limit=1

The 2nd drush command gives me an output of:

DISABLED: sos_mailchimp_sos_subscription_presave
DISABLED: sos_mailchimp_sos_subscription_update
 [notice] Processed 1 item (0 created, 1 updated, 0 failed, 0 ignored) - done with 'sos_subscription'

and whilst there are other hooks in sos_mailchimp.module, those are the only 2 that would have been invoked from this particular migration scenario, so that seems good.

Any ideas why I needed to comment that line of code out? Of course, I have to uncomment it to ensure it doesn't run on other drush commands.

Drupal 10.3.3
PHP 8.3.10
nginx/1.26.1

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Documentation

Created by

πŸ‡«πŸ‡·France paulbeaney

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

Merge Requests

Comments & Activities

  • Issue created by @paulbeaney
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    What version of Drush are you using?

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Quick disclaimer, I'm not the original author so any other advice would be greatly appreciated. I think this is generally a side effect of drush updates.

    We want to keep that alter check cause I think that keeps recursion from happening.

    So the hook implements alter alters how the implementations are called.
    Drush is supposed to boot the migrate boost.

    I tried to make it more backwards compatible with this, but something is missing.

    public static function bootDrush($command) {
        // Check if $command is an instance of ArgvInput.
        if ($command instanceof ArgvInput) {
          $command_name = $command->getFirstArgument();
        }
        else {
          // Assuming it's an array for backward compatibility.
          $command_name = $command['command'];
        }
    
        if (in_array($command_name, static::getConfig('commands'))) {
          static::enable();
        }
        else {
          static::disable();
        }
      }
    

    So for some reason the enable command is not being called which means either the command name is not picked up or the commands config is failing.

    Can you share your Drush version?

  • πŸ‡«πŸ‡·France paulbeaney

    Thanks for getting back to me and sorry for omitting that rather important bit of info! I am using drush 12.5.3.0.

    I'm not familiar with the inner workings of drush so I haven't been able to dig too deep yet, but initial debugging seems to indicate that functions such as initCommand(), boosterEnable() and bootDrush() only get called when running either of the Migrate Boost module's own commands (i.e. enable or reset). The rest of the time, the first thing that gets called seems to be MigrateBoost::alter().

    I'll keep digging and feedback anything I find and if you have any ideas of where to look, I am all ears!

  • πŸ‡«πŸ‡·France paulbeaney

    I have made what I think is some good progress on this - at least, it works, and it doesn't seem to interfere with drush commands other than the two this module is targetting. I have implemented 2 annotated hooks in MigrateBoostCommands which run before migrate:import and migrate:rollback (one callback to target each command) and simply call MigrateBoost::enable().

    I have created a fork and updated the file on GitHub, but this is my first foray into non-patch contribution, so if I need to do anything else to make it visible or otherwise complete the process, please let me know!

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Oh that looks good, I'll try to test it in a bit!

  • πŸ‡¬πŸ‡·Greece dwb17

    dwb17 β†’ changed the visibility of the branch 3472566-unable-to-disable to hidden.

  • πŸ‡¬πŸ‡·Greece dwb17

    dwb17 β†’ changed the visibility of the branch 3472566-unable-to-disable to active.

  • Merge request !7Update MigrateBoostCommands.php β†’ (Merged) created by nicxvan
  • Status changed to Fixed 24 days ago
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I've merged this in, I left it in .dev so it can be tested a bit.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024