[development] Doing hook_update_N() when module is installed

Earnie Boyd earnie at users.sourceforge.net
Fri Nov 13 18:51:20 UTC 2009

On Thu, 12 Nov 2009 Randy Fay wrote:

> I'm doing a module for infrastructure which is all about applying
> configuration updates, and it does only configuration, nothing else.
> I'd like to create hook_update_N() functions, but I'd also like all of them
> to be run when the module is installed.
> Is there any "correct" way to do this?  Many modules implement the
> functionality in both hook_install and hook_update_N, and that's fine for
> database-only issues, which is what these were built around (like schema
> changes). But it doesnt' really make sense for site config changes.
> Obviously, I can run the hook functions from hook_install(), in direct or
> indirect ways.
> Suggestions?

I think I would use a variable_set in hook_install and hook_update_N  
to say there are configuration changes and then use a hook_cron or  
batch operations to make the actual changes.  As you've noted  
hook_install and hook_update_N are reserved for DB schema changes and  
hook_enable doesn't feel correct either.  Using the variable_set you  
could create a settings tools page that will allow the user to  
re-execute the configuration changes if necessary.

-- http://r-feed.com/           -- http://for-my-kids.com/
-- http://www.4offer.biz/       -- http://give-me-an-offer.com/

More information about the development mailing list