diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index ae3f55a..dce2820 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -235,9 +235,14 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) { * The filename of the requested item or NULL if the item is not found. */ function drupal_get_filename($type, $name, $filename = NULL) { + // Return NULL right away if $type or $name is empty. + if (empty($type) || empty($name)) { + return NULL; + } + // The location of files will not change during the request, so do not use // drupal_static(). - static $files = array(); + static $files = array(), $bad = NULL; // 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 @@ -277,13 +282,24 @@ function drupal_get_filename($type, $name, $filename = NULL) { } // If still unknown, perform a filesystem scan. if (!isset($files[$type][$name])) { - $listing = new ExtensionDiscovery(DRUPAL_ROOT); - // Prevent an infinite recursion by this legacy function. - if ($original_type == 'profile') { - $listing->setProfileDirectories(array()); + if (is_null($bad)) { + $bad = array(); + if (\Drupal::hasService('cache')) { + $cache = Drupal::cache('bootstrap')->get('drupal_get_filename:bad', TRUE); + if ($cache && $cache->data) { + $bad = $cache->data; + } + } } - foreach ($listing->scan($original_type) as $extension_name => $file) { - $files[$type][$extension_name] = $file->getPathname(); + if (!isset($bad[$type][$name]) + $listing = new ExtensionDiscovery(DRUPAL_ROOT); + // Prevent an infinite recursion by this legacy function. + if ($original_type == 'profile') { + $listing->setProfileDirectories(array()); + } + foreach ($listing->scan($original_type) as $extension_name => $file) { + $files[$type][$extension_name] = $file->getPathname(); + } } } } @@ -291,6 +307,16 @@ 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; + if (\Drupal::hasService('cache'))) { + \Drupal::cache('bootstrap')->set('drupal_get_filename:bad', $bad, REQUEST_TIME); + } + if (\Drupal::hasService('logger'))) { + \Drupal::logger('system')->error('The following @type is missing from the file system: @name', array('@type' => $type, '@name' => $name)); + } + } } /** diff --git a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php index cb2833e..cbe3ae8 100644 --- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php @@ -99,7 +99,11 @@ protected function getAllFolders() { // The install profile can override module default configuration. We do // this by replacing the config file path from the module/theme with the // install profile version if there are any duplicates. - $profile_folders = $this->getComponentNames('profile', array(drupal_get_profile())); + $profile_folders = array(); + $profile = drupal_get_profile(); + if (!empty($profile)) { + $profile_folders = $this->getComponentNames('profile', array($profile)); + } $folders_to_replace = array_intersect_key($profile_folders, $this->folders); if (!empty($folders_to_replace)) { $this->folders = array_merge($this->folders, $folders_to_replace);