diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 9537049..ad82740 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -776,6 +776,8 @@ function drupal_get_filename($type, $name, $filename = NULL) { if (!isset($files[$type][$name])) { // We have consistent directory naming: modules, themes... $dir = $type . 's'; + // Always default to .info.yml extension. + $extension = 'info.yml'; if ($type == 'theme_engine') { $dir = 'themes/engines'; $extension = 'engine'; @@ -784,13 +786,6 @@ function drupal_get_filename($type, $name, $filename = NULL) { // @todo Remove false-exposure of profiles as modules. elseif ($original_type == 'profile') { $dir = 'profiles'; - $extension = 'info.yml'; - } - elseif ($type == 'theme' || $type == 'module') { - $extension = 'info.yml'; - } - else { - $extension = $type; } if (!isset($dirs[$dir][$extension])) { diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index c52961d..85decd0 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -298,6 +298,8 @@ protected function moduleData($module) { // First, find profiles. $profiles_scanner = new SystemListing(); $all_profiles = $profiles_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'profiles', 'profile'); + $this->scanForLoadFiles($profiles_scanner, $all_profiles, 'profile', 'profiles'); + $profiles = array_keys(array_intersect_key($this->moduleList, $all_profiles)); // If a module is within a profile directory but specifies another // profile for testing, it needs to be found in the parent profile. @@ -308,12 +310,43 @@ protected function moduleData($module) { } // Now find modules. $modules_scanner = new SystemListing($profiles); - $this->moduleData = $all_profiles + $modules_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'modules', 'module'); + $all_modules = $modules_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'modules', 'module'); + $this->scanForLoadFiles($modules_scanner, $all_modules, 'module', 'modules'); + + $this->moduleData = $all_profiles + $all_modules; } return isset($this->moduleData[$module]) ? $this->moduleData[$module] : FALSE; } /** + * Find out which extensions have .$type files which should later be loaded. + * + * Those files cant be autoloaded, so we need to check for their existance + * here, passing those info then to module_handler service. + * + * @param \Drupal\Core\SystemListing $scanner + * The scanner to use for finding files. + * @param array $extensions + * An array of \stdClass objects keyed by the extension name. + * A property 'loadUri' will be added to each object. If there is a file to + * be loaded then it will contain the uri relative to drupal root. NULL + * otherwise. + * @param string $type + * The extension type, eg 'module' or 'profile'. + * @param string $dir + * The directory to scan. + * + * @see \Drupal\Core\Extension\ModuleHandlerInterface::load() + */ + protected function scanForLoadFiles(SystemListing $scanner, array &$extensions, $type, $dir) { + // Find out which extensions have .$type files which should be loaded. + $need_load = $scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.' . $type . '$/', $dir, $type); + foreach ($extensions as $name => $extension) { + $extensions[$name]->loadUri = isset($need_load[$name]) ? $need_load[$name]->uri : NULL; + } + } + + /** * Implements Drupal\Core\DrupalKernelInterface::updateModules(). * * @todo Remove obsolete $module_list parameter. Only $module_filenames is @@ -638,7 +671,7 @@ protected function getModuleFileNames() { $filenames = array(); foreach ($this->moduleList as $module => $weight) { if ($data = $this->moduleData($module)) { - $filenames[$module] = $data->uri; + $filenames[$module] = !empty($data->loadUri) ? $data->loadUri : $data->uri; } } return $filenames; diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index e44d1e4..f375b34 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -89,10 +89,10 @@ public function load($name) { if (isset($this->moduleList[$name])) { $filename = DRUPAL_ROOT . '/' . $this->moduleList[$name]; - $filename = str_replace('.info.yml', '.module', $filename); - if (file_exists($filename)) { + if (!strpos($filename, '.info.yml')) { include_once $filename; } + $this->loadedFiles[$name] = TRUE; return TRUE; } @@ -589,7 +589,9 @@ public function install(array $module_list, $enable_dependencies = TRUE) { $module_filenames[$name] = $current_module_filenames[$name]; } else { - $module_filenames[$name] = drupal_get_filename('module', $name); + $filename = drupal_get_filename('module', $name); + $module_filename = dirname($filename) . "/$name.module"; + $module_filenames[$name] = file_exists($module_filename) ? $module_filename : $filename; } } diff --git a/core/modules/migrate/migrate.module b/core/modules/migrate/migrate.module deleted file mode 100644 index e69de29..0000000 diff --git a/core/modules/migrate_drupal/migrate_drupal.module b/core/modules/migrate_drupal/migrate_drupal.module deleted file mode 100644 index e69de29..0000000 diff --git a/core/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module b/core/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module deleted file mode 100644 index b3d9bbc..0000000 --- a/core/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module +++ /dev/null @@ -1 +0,0 @@ -