Commands with explicit callback functions skip drush_invoke() API

sarvab - November 7, 2009 - 03:52
Project:Drush
Version:All-Versions-HEAD
Component:Code
Category:bug report
Priority:normal
Assigned:adrian
Status:active
Description

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

moshe weitzman - November 10, 2009 - 02:59
Status:active» fixed

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

sarvab - November 10, 2009 - 04:37

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

moshe weitzman - November 10, 2009 - 05:05
Title:API command hooks» Commands with explicit callback functions skip drush_invoke() API
Category:support request» bug report
Assigned to:Anonymous» adrian
Status:fixed» active

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

sarvab - November 10, 2009 - 05:09

Great, thanks moshe! Will await further word from adrian.

#5

adrian - November 10, 2009 - 15:57

the callback support was for backward compatibility

we should remove the support for callback imo, but before that we need some documentation.

 
 

Drupal is a registered trademark of Dries Buytaert.