Fatal error: Call to undefined function menu_load_all() I have (D7) code that uses menu_load_all() to get a list of menus to pass as options for checkboxes to the admin interface of a module I'm writing.

To test and make sure my little snippet was returning the correct values for menu titles, I pasted it into a block of eval'd code in the content of my staging site, and it was fine. It returned a nice little array of titles and so I straight copy/pasted it into my module's code.

Now when I enable my module, I get this error:

Fatal error: Call to undefined function menu_load_all()


WTH? Why did this work in eval'd and not in my module, and what do I do to get my module access to this API function?

Full code of module available for your perusal.
The only thing I can of is that you're calling menu_load_all() in hook_install() or hook_enable(); all system module files aren't necessarily included when those hooks are invoked.

If that's the problem, you can force the file with the function to be included by adding the following line of code to the top of your hook_enable()/hook_install() function:

module_load_include('module', 'menu');