[development] module_exists vs. functions_exists?

Frando frando2 at unbiskant.org
Tue Jun 24 14:27:09 UTC 2008

In Drupal 7, module_invoke uses module_hook uses drupal_function_exists. I
don't see why you should not use module_invoke to call API functions.

-- Frando

Earnie wrote:
> Quoting "Daniel F. Kudwien" <news at unleashedmind.com>:
>>> 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
> For D7 it has already been stated that you want to use 
> http://api.drupal.org/api/function/drupal_function_exists/7 so that the 
> modules files are loaded as necessary.  Module_invoke is not the 
> correct thing to do unless you want to invoke hooks.
> Earnie -- http://for-my-kids.com/
> -- http://give-me-an-offer.com/

View this message in context: http://www.nabble.com/module_exists-vs.-functions_exists--tp18059424p18092252.html
Sent from the Drupal - Dev mailing list archive at Nabble.com.

More information about the development mailing list