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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mcdruid created an issue. See original summary.

mcdruid’s picture