[development] module_exists vs. functions_exists?

Daniel F. Kudwien news at unleashedmind.com
Mon Jun 23 16:38:46 UTC 2008


> While using module_invoke for things other than hooks today, 
> I do not think we should recommend it since the purpose of 
> module_invoke is to invoke the hook.  Using module_invoke for 
> more than its intended purpose is confusing and may cause 
> issues in the future should module_invoke change its ways.  
> Module_invoke is more like calling an object function while 
> executing the function directly is more like executing a 
> static class function.
> 
> Earnie

For what it's worth: Drupal's core API changes only between major versions.  As long as we're speaking of D5 and D6, and of contrib modules for D5 and D6, I would repeat my previous recommendation to a) remove unnecessary module_exists()/function_exists() code bloats, and b) manifest a best practice that can be dealt with in the module upgrade docs for D7 and/or beyond.  Until there is not a better API method, it is absolutely safe to use module_invoke().

Look, it's still there:
http://api.drupal.org/api/function/module_invoke/7

Daniel



More information about the development mailing list