Commands with explicit callback functions skip drush_invoke() API
| Project: | Drush |
| Version: | All-Versions-HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | adrian |
| Status: | active |
Jump to:
From looking through includes/commands.inc, there seems that there should be various hooks that are called for each command that is run (drush_command calling drush_invoke which calls validate, pre, post hooks)
However drush.php calls drush_dispatch which does not call drush_command so all of those valid, pre, post hooks are not called.
Is this intended and maybe I am just missing how to really take advantage of those hooks? For a better idea of what I want to do, I want to create an include svn.props.drush.inc that implements hook drush_svn_props_pre_update. For every update command that is run, I want to add a svn property with the cvs tag of the updated module to the modules folder.
Is that possible and am I heading in the wrong direction?
Thanks!

#1
The usual callback that you see in drush_dispatch is drush_command not the final command callback. drush_command does some hook_invocation and drush_invoke does more.
#2
Thanks for the response!
I see how for the download command, it is indeed drush_command which is great and works for my example above. However I was also looking to hook into pre_sql_dump as well, but drush_dispatch is not calling drush_command for sql_dump. Is there a particular reason for that?
#3
OK, it looks like commands that specify a particular callback do not currently get all their hooks run. sql query specifies a callback and thus no hooks as you have seen.
these sql command should mostly not declare explicit callback functions but thats not really relevant. this bug needs fixing.
assigning to adrian to see how he prefers to fix.
#4
Great, thanks moshe! Will await further word from adrian.
#5
the callback support was for backward compatibility
we should remove the support for callback imo, but before that we need some documentation.