diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 086f025..9537049 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -707,9 +707,9 @@ function drupal_settings_initialize() { * configuration. For example, a module 'foo' may legally be located * in any of these three places: * - * core/modules/foo/foo.module - * modules/foo/foo.module - * sites/example.com/modules/foo/foo.module + * core/modules/foo/foo.info.yml + * modules/foo/foo.info.yml + * sites/example.com/modules/foo/foo.info.yml * * Calling drupal_get_filename('module', 'foo') will give you one of * the above, depending on where the module is located. @@ -780,14 +780,14 @@ function drupal_get_filename($type, $name, $filename = NULL) { $dir = 'themes/engines'; $extension = 'engine'; } - elseif ($type == 'theme') { - $extension = 'info.yml'; - } // Profiles are converted into modules in system_rebuild_module_data(). // @todo Remove false-exposure of profiles as modules. elseif ($original_type == 'profile') { $dir = 'profiles'; - $extension = 'profile'; + $extension = 'info.yml'; + } + elseif ($type == 'theme' || $type == 'module') { + $extension = 'info.yml'; } else { $extension = $type; @@ -802,7 +802,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { // extension, not just the file we are currently looking for. This // prevents unnecessary scans from being repeated when this function is // called more than once in the same page request. - $matches = drupal_system_listing("/^" . DRUPAL_PHP_FUNCTION_PATTERN . "\.$extension$/", $dir); + $matches = drupal_system_listing("/^" . DRUPAL_PHP_FUNCTION_PATTERN . "\.$extension$/", $dir, $type); foreach ($matches as $matched_name => $file) { $files[$type][$matched_name] = $file->uri; } @@ -1032,9 +1032,11 @@ function drupal_load($type, $name) { $filename = drupal_get_filename($type, $name); if ($filename) { - include_once DRUPAL_ROOT . '/' . $filename; + $file = DRUPAL_ROOT . '/' . str_replace('info.yml', $type, $filename); + if (file_exists($file)) { + include_once $file; + } $files[$type][$name] = TRUE; - return TRUE; } diff --git a/core/includes/common.inc b/core/includes/common.inc index 91956d4..bd4da99 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3246,12 +3246,12 @@ function drupal_cron_run() { * * @see \Drupal\Core\SystemListing::scan(). */ -function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) { +function drupal_system_listing($mask, $directory, $type, $key = 'name') { // As SystemListing is required to build a dependency injection container // from scratch and SystemListingInfo only extends SystemLising, this // class needs to be hardwired. $listing = new SystemListingInfo(); - return $listing->scan($mask, $directory, $key, $min_depth); + return $listing->scan($mask, $directory, $type, $key); } /** diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index db9cf58..d7e75b2 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -543,7 +543,7 @@ function install_begin_request(&$install_state) { $install_state['database_tables_exist'] = !empty($task); // Add the list of available profiles to the installation state. - $install_state['profiles'] += drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.profile$/', 'profiles'); + $install_state['profiles'] += drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'profiles', 'profile'); } /** @@ -872,7 +872,7 @@ function install_tasks($install_state) { // Allow the installation profile to modify the full list of tasks. if (!empty($install_state['parameters']['profile'])) { $profile = $install_state['parameters']['profile']; - $profile_file = $install_state['profiles'][$profile]->uri; + $profile_file = dirname($install_state['profiles'][$profile]->uri) . '/' . $profile . '.profile'; if (file_exists($profile_file)) { include_once DRUPAL_ROOT . '/' . $profile_file; $function = $install_state['parameters']['profile'] . '_install_tasks_alter'; @@ -1907,7 +1907,7 @@ function install_already_done_error() { */ function install_load_profile(&$install_state) { $profile = $install_state['parameters']['profile']; - $profile_file = $install_state['profiles'][$profile]->uri; + $profile_file = dirname($install_state['profiles'][$profile]->uri) . '/' . $profile . '.profile'; if (file_exists($profile_file)) { include_once DRUPAL_ROOT . '/' . $profile_file; $install_state['profile_info'] = install_profile_info($install_state['parameters']['profile'], $install_state['parameters']['langcode']); diff --git a/core/includes/install.inc b/core/includes/install.inc index f6848c9..d0cca67 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -587,7 +587,7 @@ function drupal_verify_profile($install_state) { // Get a list of modules that exist in Drupal's assorted subdirectories. $present_modules = array(); - foreach (drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules') as $present_module) { + foreach (drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'modules', 'module') as $present_module) { $present_modules[] = $present_module->name; } diff --git a/core/includes/module.inc b/core/includes/module.inc index 429f5db..d97d2c7 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -285,7 +285,7 @@ function module_uninstall($module_list = array(), $uninstall_dependents = TRUE) * Returns an array of modules required by core. */ function drupal_required_modules() { - $files = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info.yml$/', 'modules'); + $files = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info.yml$/', 'modules', 'module'); $required = array(); // An installation profile is required and one must always be loaded. diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php index 16bcc1c..299a5aa 100644 --- a/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -111,8 +111,8 @@ public function listAll($prefix = '') { protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = $this->getComponentNames('profile', array(drupal_get_profile())); - $this->folders += $this->getComponentNames('module', array_keys(drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0))); - $this->folders += $this->getComponentNames('theme', array_keys(drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info.yml$/', 'themes'))); + $this->folders += $this->getComponentNames('module', array_keys(drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'modules', 'module'))); + $this->folders += $this->getComponentNames('theme', array_keys(drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'themes', 'theme'))); } return $this->folders; } diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 0160119..c52961d 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -297,7 +297,7 @@ protected function moduleData($module) { if (!$this->moduleData) { // First, find profiles. $profiles_scanner = new SystemListing(); - $all_profiles = $profiles_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.profile$/', 'profiles'); + $all_profiles = $profiles_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'profiles', 'profile'); $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,7 +308,7 @@ protected function moduleData($module) { } // Now find modules. $modules_scanner = new SystemListing($profiles); - $this->moduleData = $all_profiles + $modules_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules'); + $this->moduleData = $all_profiles + $modules_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'modules', 'module'); } return isset($this->moduleData[$module]) ? $this->moduleData[$module] : FALSE; } diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index 92cf2a4..e44d1e4 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -88,8 +88,11 @@ public function load($name) { } if (isset($this->moduleList[$name])) { - $filename = $this->moduleList[$name]; - include_once DRUPAL_ROOT . '/' . $filename; + $filename = DRUPAL_ROOT . '/' . $this->moduleList[$name]; + $filename = str_replace('.info.yml', '.module', $filename); + if (file_exists($filename)) { + include_once $filename; + } $this->loadedFiles[$name] = TRUE; return TRUE; } diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index 40e59cb..2bc6aa8 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -231,7 +231,7 @@ public function reset() { public function rebuildThemeData() { // Find themes. $listing = $this->getSystemListingInfo(); - $themes = $listing->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info.yml$/', 'themes', 'name', 1); + $themes = $listing->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info.yml$/', 'themes', 'theme'); // Allow modules to add further themes. if ($module_themes = $this->moduleHandler->invokeAll('system_theme_info')) { foreach ($module_themes as $name => $uri) { @@ -246,7 +246,7 @@ public function rebuildThemeData() { // Find theme engines. $listing = $this->getSystemListingInfo(); - $engines = $listing->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.engine$/', 'themes/engines', 'name', 1); + $engines = $listing->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.engine$/', 'themes/engines', 'engine'); // Set defaults for theme info. $defaults = array( diff --git a/core/lib/Drupal/Core/SystemListing.php b/core/lib/Drupal/Core/SystemListing.php index 20d95cb..7301d82 100644 --- a/core/lib/Drupal/Core/SystemListing.php +++ b/core/lib/Drupal/Core/SystemListing.php @@ -64,6 +64,13 @@ function __construct($profiles = array()) { * The subdirectory name in which the files are found. For example, * 'modules' will search all 'modules' directories and their * sub-directories as explained above. + * @param string $type + * The type of the extensions that should be included in results. + * Possible values are: + * - 'module' + * - 'profile' + * - 'theme' + * - 'engine' * @param string $key * (optional) The key to be used for the associative array returned. * Possible values are: @@ -81,7 +88,7 @@ function __construct($profiles = array()) { * - 'filename': File name. * - 'name': Name of file without the extension. */ - function scan($mask, $directory, $key = 'name') { + function scan($mask, $directory, $type, $key = 'name') { if (!in_array($key, array('uri', 'filename', 'name'))) { $key = 'uri'; } @@ -108,7 +115,7 @@ function scan($mask, $directory, $key = 'name') { $files = array(); // Get current list of items. foreach ($searchdir as $dir) { - $files = array_merge($files, $this->process($files, $this->scanDirectory($dir, $key, $mask, $nomask))); + $files = array_merge($files, $this->process($files, $this->scanDirectory($dir, $key, $mask, $nomask), $type)); } return $files; } @@ -140,7 +147,7 @@ protected function profiles($directory) { * The processed list of file objects. For example, the SystemListingInfo * class removes files not compatible with the current core version. */ - protected function process(array $files, array $files_to_add) { + protected function process(array $files, array $files_to_add, $type) { return $files_to_add; } @@ -203,6 +210,12 @@ protected function scanDirectory($dir, $key, $mask, $nomask) { * A file object. */ protected function processFile($file) { + // info, routing and services files have double extensions. The yaml one is + // already removed, but still the name is not actually the file name unless + // we strip the second extension as well. + $file->name = basename($file->name, '.info'); + $file->name = basename($file->name, '.routing'); + $file->name = basename($file->name, '.services'); } } diff --git a/core/lib/Drupal/Core/SystemListingInfo.php b/core/lib/Drupal/Core/SystemListingInfo.php index d302699..ce7c7b3 100644 --- a/core/lib/Drupal/Core/SystemListingInfo.php +++ b/core/lib/Drupal/Core/SystemListingInfo.php @@ -43,7 +43,7 @@ protected function profiles($directory) { /** * Overrides Drupal\Core\SystemListing::process(). */ - protected function process(array $files, array $files_to_add) { + protected function process(array $files, array $files_to_add, $type) { // Duplicate files found in later search directories take precedence over // earlier ones, so we want them to overwrite keys in our resulting // $files array. @@ -64,16 +64,13 @@ protected function process(array $files, array $files_to_add) { if (isset($info['core']) && $info['core'] != \Drupal::CORE_COMPATIBILITY) { unset($files_to_add[$file_key]); } + // If the extension is different from the requested one, remove it. + if ($info['type'] != $type) { + unset($files_to_add[$file_key]); + } } } return $files_to_add; } - /** - * Overrides Drupal\Core\SystemListing::processFile(). - */ - protected function processFile($file) { - $file->name = basename($file->name, '.info'); - } - } diff --git a/core/lib/Drupal/Core/Updater/Module.php b/core/lib/Drupal/Core/Updater/Module.php index acc3028..daab4f1 100644 --- a/core/lib/Drupal/Core/Updater/Module.php +++ b/core/lib/Drupal/Core/Updater/Module.php @@ -49,10 +49,9 @@ public function isInstalled() { * Implements Drupal\Core\Updater\UpdaterInterface::canUpdateDirectory(). */ public static function canUpdateDirectory($directory) { - if (file_scan_directory($directory, '/.*\.module$/')) { - return TRUE; - } - return FALSE; + $files = file_scan_directory($directory, '/.*\.info\.yml$/'); + $info = drupal_parse_info_file(reset($files)->uri); + return $info['type'] == 'module'; } /** diff --git a/core/lib/Drupal/Core/Updater/Theme.php b/core/lib/Drupal/Core/Updater/Theme.php index 4bd716a..3f02b0d 100644 --- a/core/lib/Drupal/Core/Updater/Theme.php +++ b/core/lib/Drupal/Core/Updater/Theme.php @@ -49,11 +49,9 @@ public function isInstalled() { * Implements Drupal\Core\Updater\UpdaterInterface::canUpdateDirectory(). */ static function canUpdateDirectory($directory) { - // This is a lousy test, but don't know how else to confirm it is a theme. - if (file_scan_directory($directory, '/.*\.module$/')) { - return FALSE; - } - return TRUE; + $files = file_scan_directory($directory, '/.*\.info\.yml$/'); + $info = drupal_parse_info_file(reset($files)->uri); + return $info['type'] == 'theme'; } /** diff --git a/core/modules/action/tests/action_bulk_test/action_bulk_test.module b/core/modules/action/tests/action_bulk_test/action_bulk_test.module deleted file mode 100644 index b3d9bbc..0000000 --- a/core/modules/action/tests/action_bulk_test/action_bulk_test.module +++ /dev/null @@ -1 +0,0 @@ - array('dir' => 'themes/engines', 'extension' => 'engine'), - 'module' => array('dir' => 'modules', 'extension' => 'module'), - 'theme' => array('dir' => 'themes', 'extension' => 'info'), - 'profile' => array('dir' => 'profiles', 'extension' => 'profile'), + 'module' => array('dir' => 'modules', 'extension' => 'info\.yml'), + 'theme' => array('dir' => 'themes', 'extension' => 'info\.yml'), + 'profile' => array('dir' => 'profiles', 'extension' => 'info\.yml'), ); $classloader = drupal_classloader(); foreach ($types as $type => $info) { - $matches = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.' . $info['extension'] . '$/', $info['dir']); + $matches = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.' . $info['extension'] . '$/', $info['dir'], $type); foreach ($matches as $name => $file) { drupal_classloader_register($name, dirname($file->uri)); $classloader->add('Drupal\\' . $name . '\\Tests', DRUPAL_ROOT . '/' . dirname($file->uri) . '/tests'); diff --git a/core/modules/statistics/tests/modules/statistics_test_views/statistics_test_views.module b/core/modules/statistics/tests/modules/statistics_test_views/statistics_test_views.module deleted file mode 100644 index e69de29..0000000 diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php index 0d11b98..b8b6ab7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php @@ -35,7 +35,7 @@ function testDrupalGetFilename() { // does not exist. $this->assertFalse(drupal_container()->has('keyvalue'), 'The container has no keyvalue service.'); // Retrieving the location of a module. - $this->assertIdentical(drupal_get_filename('module', 'xmlrpc'), 'core/modules/xmlrpc/xmlrpc.module', 'Retrieve module location.'); + $this->assertIdentical(drupal_get_filename('module', 'xmlrpc'), 'core/modules/xmlrpc/xmlrpc.info.yml', 'Retrieve module location.'); // Retrieving the location of a theme. $this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml', 'Retrieve theme location.'); @@ -45,7 +45,7 @@ function testDrupalGetFilename() { // Retrieving the location of a profile. Profiles are a special case with // a fixed location and naming. - $this->assertIdentical(drupal_get_filename('profile', 'standard'), 'core/profiles/standard/standard.profile', 'Retrieve installation profile location.'); + $this->assertIdentical(drupal_get_filename('profile', 'standard'), 'core/profiles/standard/standard.info.yml', 'Retrieve installation profile location.'); // When a file is not found in the database cache, drupal_get_filename() // searches several locations on the filesystem, including the core/ diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/SystemListingTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/SystemListingTest.php index ee1f12b..23303db 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/SystemListingTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/SystemListingTest.php @@ -48,17 +48,17 @@ function testDirectoryPrecedence() { // meaning, so assert their presence first. foreach ($expected_directories as $module => $directories) { foreach ($directories as $directory) { - $filename = "$directory/$module/$module.module"; + $filename = "$directory/$module/$module.info.yml"; $this->assertTrue(file_exists(DRUPAL_ROOT . '/' . $filename), format_string('@filename exists.', array('@filename' => $filename))); } } // Now scan the directories and check that the files take precedence as // expected. - $files = drupal_system_listing('/\.module$/', 'modules'); + $files = drupal_system_listing('/\.info\.yml$/', 'modules', 'module'); foreach ($expected_directories as $module => $directories) { $expected_directory = array_shift($directories); - $expected_filename = "$expected_directory/$module/$module.module"; + $expected_filename = "$expected_directory/$module/$module.info.yml"; $this->assertEqual($files[$module]->uri, $expected_filename, format_string('Module @module was found at @filename.', array('@module' => $module, '@filename' => $expected_filename))); } } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 859b2a1..0862d60 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -5,12 +5,11 @@ * Configuration system that lets administrators modify the workings of the site. */ -use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Language\Language; use Drupal\Core\Utility\ModuleInfo; +use Drupal\Core\SystemListingInfo; use Drupal\user\UserInterface; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; use Guzzle\Http\Exception\BadResponseException; @@ -2317,11 +2316,12 @@ function system_get_module_info($property) { * An associative array of module information. */ function _system_rebuild_module_data() { + $scanner = new SystemListingInfo(); // Find modules - $modules = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0); + $modules = $scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'modules', 'module'); // Find installation profiles. - $profiles = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.profile$/', 'profiles', 'name', 0); + $profiles = $scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info\.yml$/', 'profiles', 'profile'); // Include the installation profile in modules that are loaded. $profile = drupal_get_profile(); diff --git a/core/modules/system/tests/modules/action_test/action_test.module b/core/modules/system/tests/modules/action_test/action_test.module deleted file mode 100644 index b3d9bbc..0000000 --- a/core/modules/system/tests/modules/action_test/action_test.module +++ /dev/null @@ -1 +0,0 @@ -/ KNXU -'AbھsM( \ No newline at end of file +2Qaaa_update_test.tar.gzj p} +riѻ<"v&1оt]a]le}?rrRj;{F3r z>hB#}Z4.п + YZ( \ No newline at end of file diff --git a/core/modules/update/tests/aaa_update_test/aaa_update_test.module b/core/modules/update/tests/aaa_update_test/aaa_update_test.module deleted file mode 100644 index 4d67b8e..0000000 --- a/core/modules/update/tests/aaa_update_test/aaa_update_test.module +++ /dev/null @@ -1,6 +0,0 @@ -systemListingInfo->expects($this->at(0)) ->method('scan') - ->with($this->anything(), 'themes', 'name', 1) + ->with($this->anything(), 'themes', 'theme') ->will($this->returnValue(array( 'seven' => (object) array( 'name' => 'seven',