A contributed module that I am using [popup_forms] uses module_invoke_all to check whether any modules have defined a form for it to use.
I have defined the necessary function called mymodule_popup_forms_data() that provides the information that popup_forms needs.
If I locate that function within mymodule.module, all works well.
If, however, I move that function to a mymodule.inc file, then the module_invoke_all in popup_forms does not find my function.
This despite trying a very large number of variations of module_load_include, include_once etc. etc. etc. I think that there might be a hint to what is going on in a greg.harvey comment five years ago:
"Worth noting, if you want to include data (e.g. a views object) in an include file, you cannot use this function - because the data will only be available within the scope of module_load_include() function, not within your own function that invoked it."
Hence the question: Is it true that a function defined in a .inc file that is included via a module_load_include call will not be "in scope" for module_invoke_all?
Comments
Comment #2
cilefen CreditAttribution: cilefen commentedHave you tried the files[] key to specify the .inc file in your module info file?
Comment #3
cilefen CreditAttribution: cilefen commentedOr, require_once() the .inc file in your .module file? There is no way Drupal will know to load the functions some .inc file unless it is referenced somewhere.