At the start of filefield_paths.module there's some code which calls module_list() in the global context (i.e. outside of a hook or function):
/**
* Include additional files.
*/
$dirname = dirname(__FILE__) . "/modules";
$includes = file_scan_directory($dirname, '/.inc$/');
foreach (module_list() as $module) {
if (isset($includes[$file = "{$dirname}/{$module}.inc"])) {
require_once $file;
}
}
Calling Drupal API functions outside of hooks/functions can cause performance problems and/or have unpredictable consequences such as "cache poisoning" as Drupal will not be fully bootstrapped when this code runs.
In this case module_list() may not return the full list of installed modules - see the docs page:
Usually, this returns a list of all enabled modules. When called early on in the bootstrap, it will return a list of vital modules only (those needed to generate cached pages).
One simple way to address this would be to move this code into an implementation of hook_init.
Comment | File | Size | Author |
---|---|---|---|
#3 | avoid_global_function_calls-2879761-3.patch | 827 bytes | mcdruid |
Comments
Comment #2
mcdruidComment #3
mcdruidFixed a comment typo in the previous patch.