[development] module_exists vs. functions_exists?
Earnie Boyd
earnie at users.sourceforge.net
Mon Jun 23 17:59:29 UTC 2008
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/
More information about the development
mailing list