Module name error on deploy:hook when module name contains _deploy #5112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello;
I noticed a rather specific error when the module's name contains the substring
_deploy
on its name.Take
mymodule_deploy
as an example, with amymodule_deploy_deploy_myfunction
deploy hook and amymodule_deploy.deploy.php
file.Running drush deploy:hook will fail with the following error:
This is because
list($module, $name) = explode('_deploy_', $function, 2);
will set$module
to justmymodule
and notmymodule_deploy
and, thus, the$filename
will be wrong.This is an uncommon but not rare scenario. In fact, it happened to me because I had a separate custom module dedicated to deploy hooks that had the
deploy
substring on the name.The attached patch tries to solve this by first locating the deploy name and then substracting it from the function name in order to get the real module name.