module_invoke() is used to call core API functions in a special core API class called hooks. If your function is not part of the core API, then using module_invoke to call it is misleading. Misleading code is a maintenance problem. Some day, the functionality of module_invoke() may change and not work correctly to call random contributed module functions. It will always work to call hooks, however. Hence, by definition, it is wrong to use it for a purpose it was not meant. <br>
<br><div class="gmail_quote">On Tue, Jun 24, 2008 at 2:31 PM, Michael Prasuhn <<a href="mailto:mike@mikeyp.net">mike@mikeyp.net</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On Jun 24, 2008, at 11:32 AM, Damien wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Tue, Jun 24, 2008 at 7:50 PM, Michael Prasuhn <<a href="mailto:mike@mikeyp.net" target="_blank">mike@mikeyp.net</a>> 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?<br>
<br>
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.<br>
<br>
Using module_invoke() here would be bad practice at best, but could also be dangerous.<br>
</blockquote>
<br>
<br></div></div>
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.<br>
<br>
-Mike<br><br></blockquote></div><br>