Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drush hook_deploy_NAME calls non-deploy hooks in .module when the module name contains _deploy #6159

Open
timwood opened this issue Nov 13, 2024 · 0 comments

Comments

@timwood
Copy link

timwood commented Nov 13, 2024

Describe the bug
We have a module name containing _deploy and in the .module file we have various Drupal hooks (eg. hook_form_FORM_ID_alter). After upgrading to Drupal 10.3, Drush 12.5.3 is calling these hooks because our module name or hook name. Drush deploy is then failing with this error:

>  [notice] Deploy hook started: woot_deploy_form_node_page_edit_form_alter
>  [notice] Performed: woot_deploy_form_node_page_edit_form_alter
>  [notice] Deploy hook started: woot_deploy_form_node_page_form_alter
>  [error]  ArgumentCountError: Too few arguments to function woot_deploy_form_node_page_form_alter(), 1 passed in /vendor/drush/drush/src/Commands/core/DeployHookCommands.php on line 187 and exactly 3 expected in woot_deploy_form_node_page_form_alter() (line 79 of /docroot/modules/custom/woot_deploy/woot_deploy.module) #0 /vendor/drush/drush/src/Commands/core/DeployHookCommands.php(187): woot_deploy_form_node_page_form_alter(Array)

To Reproduce
Have a module including _deploy at the end of the name and add any Drupal hook to the .module file. eg:

function woot_deploy_form_node_page_edit_form_alter(&$form, FormStateInterface &$form_state, $form_id) {
  Do stuff here;
}

Expected behavior
Don't run/call non-deploy hooks.

Actual behavior
hook_form_FORM_ID_alter is being run as a deploy hook.

Workaround
If all arguments have default values and we add check code, Drush deploy likely won't fail, but I didn't get that far with it.

Alternatively moving the Drupal hooks to a module with a name that doesn't include _deploy works.

System Configuration

Q A
Drush version? 12.5.3
Drupal version? 10.3.8
PHP version 8.2.22
OS? Linux

Additional information
Related to #5216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants