diff -u b/core/includes/file.inc b/core/includes/file.inc --- b/core/includes/file.inc +++ b/core/includes/file.inc @@ -1443,32 +1443,37 @@ $files = array(); // Avoid warnings when opendir does not have the permissions to open a // directory. - if (is_dir($dir) && $handle = @opendir($dir)) { - while (FALSE !== ($filename = readdir($handle))) { - if (!preg_match($options['nomask'], $filename) && $filename[0] != '.') { - $uri = "$dir/$filename"; - $uri = file_stream_wrapper_uri_normalize($uri); - if (is_dir($uri) && $options['recurse']) { - // Give priority to files in this folder by merging them in after any subdirectory files. - $files = array_merge(file_scan_directory($uri, $mask, $options, $depth + 1), $files); - } - elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) { - // Always use this match over anything already set in $files with the - // same $$options['key']. - $file = new stdClass(); - $file->uri = $uri; - $file->filename = $filename; - $file->name = pathinfo($filename, PATHINFO_FILENAME); - $key = $options['key']; - $files[$file->$key] = $file; - if ($options['callback']) { - $options['callback']($uri); + if (is_dir($dir)) { + if($handle = @opendir($dir)) { + while (FALSE !== ($filename = readdir($handle))) { + if (!preg_match($options['nomask'], $filename) && $filename[0] != '.') { + $uri = "$dir/$filename"; + $uri = file_stream_wrapper_uri_normalize($uri); + if (is_dir($uri) && $options['recurse']) { + // Give priority to files in this folder by merging them in after any subdirectory files. + $files = array_merge(file_scan_directory($uri, $mask, $options, $depth + 1), $files); + } + elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) { + // Always use this match over anything already set in $files with the + // same $$options['key']. + $file = new stdClass(); + $file->uri = $uri; + $file->filename = $filename; + $file->name = pathinfo($filename, PATHINFO_FILENAME); + $key = $options['key']; + $files[$file->$key] = $file; + if ($options['callback']) { + $options['callback']($uri); + } } } } - } - closedir($handle); + closedir($handle); + } + else { + watchdog('file', '@dir can not be opened', array('@dir' => $dir), WATCHDOG_ERROR); + } } return $files; diff -u b/core/includes/install.core.inc b/core/includes/install.core.inc --- b/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1466,10 +1466,6 @@ module_list_reset(); // Instantiate a new kernel that will not compile the container. - // @todo The first two constructor parameters for the Kernel class are for - // environment, e.g. 'prod', 'dev', and a boolean indicating whether it is - // in debug mode. Drupal does not currently make use of either of these, - // though that may change with http://drupal.org/node/1537198. $kernel = new DrupalKernel('prod', FALSE, NULL, FALSE); $kernel->boot(); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); diff -u b/core/includes/module.inc b/core/includes/module.inc --- b/core/includes/module.inc +++ b/core/includes/module.inc @@ -188,16 +188,13 @@ // Build a list of all enabled modules. $lists['module_enabled'][$name] = $name; // Build a list of filenames so drupal_get_filename can use it. - $lists['filepaths'][] = array( + $lists['filepaths'][$name] = array( 'type' => 'module', 'name' => $name, 'filepath' => $module_files[$name], ); } - // Store a hash of the enabled modules for use when compiling the DIC. - $lists['module_enabled_hash'] = hash('sha256', implode(',', array_keys($lists['module_enabled']))); - // Build a list of themes. $enabled_themes = config('system.theme')->get('enabled'); // @todo Themes include all themes, including disabled/uninstalled. This @@ -218,7 +215,7 @@ $lists['theme'][$name] = $theme; // Build a list of filenames so drupal_get_filename can use it. if (isset($enabled_themes[$name])) { - $lists['filepaths'][] = array( + $lists['filepaths'][$name] = array( 'type' => 'theme', 'name' => $name, 'filepath' => $theme->filename, @@ -252,6 +249,9 @@ // Set the theme engine prefix. $lists['theme'][$key]->prefix = ($lists['theme'][$key]->info['engine'] == 'theme') ? $base_key : $lists['theme'][$key]->info['engine']; } + // Store a hash of the enabled modules for use when compiling the DIC. + $lists['system_list_hash'] = hash('sha256', implode(',', array_keys($lists['filepaths']))); + cache('bootstrap')->set('system_list', $lists); } // To avoid a separate database lookup for the filepath, prime the diff -u b/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php --- b/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -48,7 +48,20 @@ */ protected $storage; - public function __construct($environment, $debug, $system_list = NULL, $use_compiled_container = TRUE) { + /** + * @todo The first two constructor parameters for the Kernel class are for + * environment, e.g. 'prod', 'dev', and a boolean indicating whether it is + * in debug mode. Drupal does not currently make use of either of these, + * though that may change with http://drupal.org/node/1537198. + * + * @param string $environment + * @param bool $debug + * @param array $system_list + * The same data structure as system_list(). + * @param bool $use_compiled_container + * Whether to compile the container to disk or not. + */ + public function __construct($environment, $debug, array $system_list = NULL, $use_compiled_container = TRUE) { parent::__construct($environment, $debug); $this->useCompiledContainer = $use_compiled_container; $this->storage = drupal_php_storage('service_container'); @@ -102,11 +115,8 @@ * the old files. See http://drupal.org/node/1759582. */ protected function initializeContainer() { - if (!$this->useCompiledContainer) { - // In debug mode we do not use a compiled container. - $this->container = $this->buildContainer(); - } - else { + $this->container = NULL; + if ($this->useCompiledContainer) { // While the default Symfony class name only depends on the environment, for // testing purposes we can't use that because there would be a collision as // each test method creates a new kernel. On the other hand, the container @@ -118,7 +128,7 @@ // needing to rebuild the DIC at the right time on module enable: simply on // the next request the hash will change and so the container will be // rebuilt. - $class = 'c' . $this->systemList['module_enabled_hash'] . ucfirst($this->environment) . ($this->debug ? 'Debug' : ''); + $class = 'c' . $this->systemList['system_list_hash'] . ucfirst($this->environment) . ($this->debug ? 'Debug' : ''); $cache_file = $class . '.php'; // First, try to load. @@ -127,15 +137,16 @@ } // If the load succeeded or the class already existed, use it. if (class_exists($class)) { - $this->container = new $class; + $fully_qualified_classname = '\\' . $class; + $this->container = new $fully_qualified_classname; } - else { - $this->container = $this->buildContainer(); - if (!$this->dumpDrupalContainer($cache_file, $this->container, $class, $this->getContainerBaseClass())) { - // We want to log this as an error but we cannot call watchdog() until - // the container has been fully built and set in drupal_container(). - $error = 'Container cannot be written to disk'; - } + } + if (!isset($this->container)) { + $this->container = $this->buildContainer(); + if ($this->useCompiledContainer && !$this->dumpDrupalContainer($cache_file, $this->container, $class, $this->getContainerBaseClass())) { + // We want to log this as an error but we cannot call watchdog() until + // the container has been fully built and set in drupal_container(). + $error = 'Container cannot be written to disk'; } }