diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 1cd178c..eddbcc0 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -237,7 +237,7 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) { function drupal_get_filename($type, $name, $filename = NULL) { // The location of files will not change during the request, so do not use // drupal_static(). - static $files = array(); + static $files = array(), $bad = array(); // Type 'core' only exists to simplify application-level logic; it always maps // to the /core directory, whereas $name is ignored. It is only requested via @@ -261,22 +261,32 @@ function drupal_get_filename($type, $name, $filename = NULL) { $files[$type][$name] = $filename; } elseif (!isset($files[$type][$name])) { + if (empty($bad)) { + $cache = \Drupal::cache('bootstrap')->get('drupal_get_filename:bad', TRUE); + if ($cache && $cache->data) { + $bad = $cache->data; + } + else { + $bad = array(); + } + } + // If the pathname of the requested extension is not known, try to retrieve // the list of extension pathnames from various providers, checking faster // providers first. // Retrieve the current module list (derived from the service container). - if ($type == 'module' && \Drupal::hasService('module_handler')) { + if (!isset($bad[$type][$name]) && $type == 'module' && \Drupal::hasService('module_handler')) { foreach (\Drupal::moduleHandler()->getModuleList() as $module_name => $module) { $files[$type][$module_name] = $module->getPathname(); } } // If still unknown, retrieve the file list prepared in state by // system_rebuild_module_data() and system_rebuild_theme_data(). - if (!isset($files[$type][$name]) && \Drupal::hasService('state')) { + if (!isset($bad[$type][$name]) && !isset($files[$type][$name]) && \Drupal::hasService('state')) { $files[$type] += \Drupal::state()->get('system.' . $type . '.files', array()); } // If still unknown, perform a filesystem scan. - if (!isset($files[$type][$name])) { + if (!isset($bad[$type][$name]) && !isset($files[$type][$name])) { $listing = new ExtensionDiscovery(DRUPAL_ROOT); // Prevent an infinite recursion by this legacy function. if ($original_type == 'profile') { @@ -291,6 +301,12 @@ function drupal_get_filename($type, $name, $filename = NULL) { if (isset($files[$type][$name])) { return $files[$type][$name]; } + elseif (!isset($bad[$type][$name])) { + // Add the missing file to a temporary cache and throw an alert. + $bad[$type][$name] = TRUE; + \Drupal::cache('bootstrap')->set('drupal_get_filename:bad', $bad, REQUEST_TIME); + \Drupal::logger('system')->error('The following @type is missing from the file system: @name', array('@type' => $type, '@name' => $name)); + } } /**