[development] module_exists vs. functions_exists?

Michael Prasuhn mike at mikeyp.net
Tue Jun 24 19:31:36 UTC 2008

On Jun 24, 2008, at 11:32 AM, Damien wrote:
> On Tue, Jun 24, 2008 at 7:50 PM, Michael Prasuhn <mike at mikeyp.net>  
> wrote, about module_invoke(): I don't buy it. This looks like an  
> excellent use of an existing function that does exactly what is  
> called for. What defines a 'hook' anyway? Is a function not a hook  
> if only one module implements it? Would it be such a stretch to  
> think of every function as a hook to be invoked in multiple  
> different ways?
> It doesn't make sense to use module_invoke() in the stated case  
> (calling a specific API function of a module). module_invoke() does  
> not do any error checking, and it does not report anything useful.  
> You should call drupal_functon_exists() directly and act accordingly  
> in case of errors.
> Using module_invoke() here would be bad practice at best, but could  
> also be dangerous.

Once again, I don't buy it. If you have to switch off of whether the  
function exists, then by all means do that. But for Drupal 6  
development I see no issue with using module_invoke. If you can't be  
bothered to test your code to make sure what it depends on is there,  
then your code has deeper issues than the method used to interface  
with another API.

Michael Prasuhn
mike at mikeyp.net

More information about the development mailing list