Commit eba0b718 authored by alexpott's avatar alexpott

Revert "Issue #340723 by ParisLiakos, sun, Berdir, glennpratt, Cottser,...

Revert "Issue #340723 by ParisLiakos, sun, Berdir, glennpratt, Cottser, swentel, tstoeckler, Xano, tim.plunkett, BassistJimmyJam: Make modules and installation profiles only require .info.yml files."

This reverts commit b4c561d0.
parent 25b100cf
......@@ -65,8 +65,9 @@ function authorize_access_allowed() {
// We have to enable the user and system modules, even to check access and
// display errors via the maintenance theme.
\Drupal::moduleHandler()->addModule('system', 'core/modules/system');
\Drupal::moduleHandler()->addModule('user', 'core/modules/user');
$module_list['system'] = 'core/modules/system/system.module';
$module_list['user'] = 'core/modules/user/user.module';
\Drupal::moduleHandler()->setModuleList($module_list);
\Drupal::moduleHandler()->load('system');
\Drupal::moduleHandler()->load('user');
......
......@@ -552,9 +552,9 @@ function _drupal_request_initialize() {
* configuration. For example, a module 'foo' may legally be located
* in any of these three places:
*
* core/modules/foo/foo.info.yml
* modules/foo/foo.info.yml
* sites/example.com/modules/foo/foo.info.yml
* core/modules/foo/foo.module
* modules/foo/foo.module
* sites/example.com/modules/foo/foo.module
*
* Calling drupal_get_filename('module', 'foo') will give you one of
* the above, depending on where the module is located.
......@@ -594,9 +594,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
// providers first.
// Retrieve the current module list (derived from the service container).
if ($type == 'module' && \Drupal::hasService('module_handler')) {
foreach (\Drupal::moduleHandler()->getModuleList() as $module_name => $module) {
$files[$type][$module_name] = $module->getPathname();
}
$files[$type] += \Drupal::moduleHandler()->getModuleList();
}
// If still unknown, retrieve the file list prepared in state by
// system_rebuild_module_data() and system_rebuild_theme_data().
......@@ -611,7 +609,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
$listing->setProfileDirectories(array());
}
foreach ($listing->scan($original_type) as $extension_name => $file) {
$files[$type][$extension_name] = $file->getPathname();
$files[$type][$extension_name] = $file->uri;
}
}
}
......
......@@ -4944,9 +4944,9 @@ function drupal_flush_all_caches() {
// sufficient, since the list of enabled modules might have been adjusted
// above due to changed code.
$files = array();
foreach ($module_data as $name => $extension) {
if ($extension->status) {
$files[$name] = $extension;
foreach ($module_data as $module => $data) {
if (isset($data->uri) && $data->status) {
$files[$module] = $data->uri;
}
}
\Drupal::service('kernel')->updateModules($module_handler->getModuleList(), $files);
......
......@@ -386,7 +386,7 @@ function install_begin_request(&$install_state) {
// Prime drupal_get_filename()'s static cache.
foreach ($install_state['profiles'] as $name => $profile) {
drupal_get_filename('profile', $name, $profile->getPathname());
drupal_get_filename('profile', $name, $profile->uri);
}
if ($profile = _install_select_profile($install_state)) {
......@@ -399,12 +399,14 @@ function install_begin_request(&$install_state) {
// Override the module list with a minimal set of modules.
$module_handler = \Drupal::moduleHandler();
$module_list = $module_handler->getModuleList();
if (!$module_handler->moduleExists('system')) {
$module_handler->addModule('system', 'core/modules/system');
$module_list['system'] = 'core/modules/system/system.module';
}
if ($profile && !$module_handler->moduleExists($profile)) {
$module_handler->addProfile($profile, $install_state['profiles'][$profile]->getPath());
$module_list[$profile] = $install_state['profiles'][$profile]->uri;
}
$module_handler->setModuleList($module_list);
// After setting up a custom and finite module list in a custom low-level
// bootstrap like here, ensure to use ModuleHandler::loadAll() so that
// ModuleHandler::isLoaded() returns TRUE, since that is a condition being
......@@ -732,7 +734,9 @@ 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'];
if ($install_state['profiles'][$profile]->load()) {
$profile_file = $install_state['profiles'][$profile]->uri;
if (file_exists($profile_file)) {
include_once DRUPAL_ROOT . '/' . $profile_file;
$function = $install_state['parameters']['profile'] . '_install_tasks_alter';
if (function_exists($function)) {
$function($tasks, $install_state);
......@@ -1761,12 +1765,19 @@ function _install_get_version_info($version) {
*
* @param $install_state
* An array of information about the current installation state. The loaded
* profile information will be added here.
* profile information will be added here, or an exception will be thrown if
* the profile cannot be loaded.
*/
function install_load_profile(&$install_state) {
$profile = $install_state['parameters']['profile'];
$install_state['profiles'][$profile]->load();
$install_state['profile_info'] = install_profile_info($profile, isset($install_state['parameters']['langcode']) ? $install_state['parameters']['langcode'] : 'en');
$profile_file = $install_state['profiles'][$profile]->uri;
if (file_exists($profile_file)) {
include_once DRUPAL_ROOT . '/' . $profile_file;
$install_state['profile_info'] = install_profile_info($install_state['parameters']['profile'], isset($install_state['parameters']['langcode']) ? $install_state['parameters']['langcode'] : 'en');
}
else {
throw new InstallerException(t('Sorry, the profile you have chosen cannot be loaded.'));
}
}
/**
......
......@@ -659,9 +659,8 @@ function drupal_install_system($install_state) {
->save();
// Update the module list to include it. Reboot the kernel too.
\Drupal::moduleHandler()->addModule('system', 'core/modules/system');
$module_list = \Drupal::moduleHandler()->getModuleList();
$kernel->updateModules($module_list);
\Drupal::moduleHandler()->setModuleList(array('system' => $system_path . '/system.module'));
$kernel->updateModules(array('system' => $system_path . '/system.module'));
\Drupal::service('config.installer')->installDefaultConfig('module', 'system');
......
......@@ -72,8 +72,9 @@ function _drupal_maintenance_theme() {
// Ensure that system.module is loaded.
if (!function_exists('_system_rebuild_theme_data')) {
$module_list['system'] = 'core/modules/system/system.module';
$module_handler = \Drupal::moduleHandler();
$module_handler->addModule('system', 'core/modules/system');
$module_handler->setModuleList($module_list);
$module_handler->load('system');
}
......
......@@ -82,9 +82,12 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
protected $newModuleList;
/**
* List of available modules and installation profiles.
* An array of module data objects.
*
* @var \Drupal\Core\Extension\Extension[]
* The data objects have the same data structure as returned by
* ExtensionDiscovery but only the uri property is used.
*
* @var array
*/
protected $moduleData = array();
......@@ -327,8 +330,8 @@ protected function moduleData($module) {
*/
public function updateModules(array $module_list, array $module_filenames = array()) {
$this->newModuleList = $module_list;
foreach ($module_filenames as $name => $extension) {
$this->moduleData[$name] = $extension;
foreach ($module_filenames as $module => $filename) {
$this->moduleData[$module] = (object) array('uri' => $filename);
}
// If we haven't yet booted, we don't need to do anything: the new module
// list will take effect when boot() is called. If we have already booted,
......@@ -410,7 +413,7 @@ protected function initializeContainer() {
// from the container.
$container_modules = $this->container->getParameter('container.modules');
$namespaces_before = $this->classLoader->getPrefixes();
$this->registerNamespaces($this->container->getParameter('container.namespaces'));
$this->registerNamespaces($this->getModuleNamespaces($container_modules));
// If 'container.modules' is wrong, the container must be rebuilt.
if (!isset($this->moduleList)) {
......@@ -498,7 +501,7 @@ protected function buildContainer() {
$container = $this->getContainerBuilder();
$container->set('kernel', $this);
$container->setParameter('container.service_providers', $this->serviceProviderClasses);
$container->setParameter('container.modules', $this->getModulesParameter());
$container->setParameter('container.modules', $this->getModuleFileNames());
// Get a list of namespaces and put it onto the container.
$namespaces = $this->getModuleNamespaces($this->getModuleFileNames());
......@@ -661,25 +664,6 @@ protected function getConfigStorage() {
return $this->configStorage;
}
/**
* Returns an array of Extension class parameters for all enabled modules.
*
* @return array
*/
protected function getModulesParameter() {
$extensions = array();
foreach ($this->moduleList as $name => $weight) {
if ($data = $this->moduleData($name)) {
$extensions[$name] = array(
'type' => $data->getType(),
'pathname' => $data->getPathname(),
'filename' => $data->getExtensionFilename(),
);
}
}
return $extensions;
}
/**
* Returns the file name for each enabled module.
*/
......@@ -687,7 +671,7 @@ protected function getModuleFileNames() {
$filenames = array();
foreach ($this->moduleList as $module => $weight) {
if ($data = $this->moduleData($module)) {
$filenames[$module] = $data->getPathname();
$filenames[$module] = $data->uri;
}
}
return $filenames;
......
......@@ -61,7 +61,7 @@ class Extension implements \Serializable {
*
* @todo Rename to $filename once external test dependencies are resolved.
*
* @var string|null
* @var string
*/
protected $_filename;
......@@ -83,9 +83,9 @@ class Extension implements \Serializable {
* The relative path and filename of the extension's info file; e.g.,
* 'core/modules/node/node.info.yml'.
* @param string $filename
* (optional) The filename of the main extension file; e.g., 'node.module'.
* The filename of the main extension file; e.g., 'node.module'.
*/
public function __construct($type, $pathname, $filename = NULL) {
public function __construct($type, $pathname, $filename) {
$this->type = $type;
$this->pathname = $pathname;
$this->_filename = $filename;
......@@ -140,40 +140,6 @@ public function getFilename() {
return basename($this->pathname);
}
/**
* Returns the relative path of the main extension file, if any.
*
* @return string|null
*/
public function getExtensionPathname() {
if ($this->_filename) {
return $this->getPath() . '/' . $this->_filename;
}
}
/**
* Returns the name of the main extension file, if any.
*
* @return string|null
*/
public function getExtensionFilename() {
return $this->_filename;
}
/**
* Loads the main extension file, if any.
*
* @return bool
* TRUE if this extension has a main extension file, FALSE otherwise.
*/
public function load() {
if ($this->_filename) {
include_once DRUPAL_ROOT . '/' . $this->getPath() . '/' . $this->_filename;
return TRUE;
}
return FALSE;
}
/**
* Re-routes method calls to SplFileInfo.
*
......
......@@ -375,9 +375,6 @@ protected function scanDirectory($dir, $include_tests) {
else {
$filename = $name . '.' . $type;
}
if (!file_exists(dirname($pathname) . '/' . $filename)) {
$filename = NULL;
}
$extension = new Extension($type, $pathname, $filename);
// Inject the existing RecursiveDirectoryIterator object to avoid
......
......@@ -30,7 +30,9 @@ class ModuleHandler implements ModuleHandlerInterface {
/**
* List of installed modules.
*
* @var \Drupal\Core\Extension\Extension[]
* @var array
* An associative array whose keys are the names of the modules and whose
* values are the module filenames.
*/
protected $moduleList;
......@@ -67,17 +69,14 @@ class ModuleHandler implements ModuleHandlerInterface {
*
* @param array $module_list
* An associative array whose keys are the names of installed modules and
* whose values are Extension class parameters. This is normally the
* whose values are the module filenames. This is normally the
* %container.modules% parameter being set up by DrupalKernel.
*
* @see \Drupal\Core\DrupalKernel
* @see \Drupal\Core\CoreServiceProvider
*/
public function __construct(array $module_list = array()) {
$this->moduleList = array();
foreach ($module_list as $name => $module) {
$this->moduleList[$name] = new Extension($module['type'], $module['pathname'], $module['filename']);
}
$this->moduleList = $module_list;
}
/**
......@@ -89,7 +88,8 @@ public function load($name) {
}
if (isset($this->moduleList[$name])) {
$this->moduleList[$name]->load();
$filename = $this->moduleList[$name];
include_once DRUPAL_ROOT . '/' . $filename;
$this->loadedFiles[$name] = TRUE;
return TRUE;
}
......@@ -101,8 +101,8 @@ public function load($name) {
*/
public function loadAll() {
if (!$this->loaded) {
foreach ($this->moduleList as $name => $module) {
$this->load($name);
foreach ($this->moduleList as $module => $filename) {
$this->load($module);
}
$this->loaded = TRUE;
}
......@@ -140,37 +140,6 @@ public function setModuleList(array $module_list = array()) {
$this->resetImplementations();
}
/**
* {@inheritdoc}
*/
public function addModule($name, $path) {
$this->add('module', $name, $path);
}
/**
* {@inheritdoc}
*/
public function addProfile($name, $path) {
$this->add('profile', $name, $path);
}
/**
* Adds a module or profile to the list of currently active modules.
*
* @param string $type
* The extension type; either 'module' or 'profile'.
* @param string $name
* The module name; e.g., 'node'.
* @param string $path
* The module path; e.g., 'core/modules/node'.
*/
protected function add($type, $name, $path) {
$pathname = "$path/$name.info.yml";
$filename = file_exists("$path/$name.$type") ? "$name.$type" : NULL;
$this->moduleList[$name] = new Extension($type, $pathname, $filename);
$this->resetImplementations();
}
/**
* Implements \Drupal\Core\Extension\ModuleHandlerInterface::buildModuleDependencies().
*/
......@@ -221,7 +190,7 @@ public function loadInclude($module, $type, $name = NULL) {
$name = $name ?: $module;
if (isset($this->moduleList[$module])) {
$file = DRUPAL_ROOT . '/' . $this->moduleList[$module]->getPath() . "/$name.$type";
$file = DRUPAL_ROOT . '/' . dirname($this->moduleList[$module]) . "/$name.$type";
if (is_file($file)) {
require_once $file;
return $file;
......@@ -617,10 +586,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
$module_filenames[$name] = $current_module_filenames[$name];
}
else {
$module_path = drupal_get_path('module', $name);
$pathname = "$module_path/$name.info.yml";
$filename = file_exists($module_path . "/$name.module") ? "$name.module" : NULL;
$module_filenames[$name] = new Extension('module', $pathname, $filename);
$module_filenames[$name] = drupal_get_filename('module', $name);
}
}
......@@ -852,8 +818,8 @@ protected function removeCacheBins($module) {
*/
public function getModuleDirectories() {
$dirs = array();
foreach ($this->getModuleList() as $name => $module) {
$dirs[$name] = DRUPAL_ROOT . '/' . $module->getPath();
foreach ($this->getModuleList() as $module => $filename) {
$dirs[$module] = DRUPAL_ROOT . '/' . dirname($filename);
}
return $dirs;
}
......
......@@ -49,43 +49,23 @@ public function isLoaded();
public function reload();
/**
* Returns the list of currently active modules.
* Returns a list of currently active modules.
*
* @return \Drupal\Core\Extension\Extension[]
* @return array
* An associative array whose keys are the names of the modules and whose
* values are Extension objects.
* values are the module filenames.
*/
public function getModuleList();
/**
* Sets an explicit list of currently active modules.
* Explicitly sets the moduleList property to the passed in array of modules.
*
* @param \Drupal\Core\Extension\Extension[] $module_list
* @param array $module_list
* An associative array whose keys are the names of the modules and whose
* values are Extension objects.
* values are the module filenames.
*/
public function setModuleList(array $module_list = array());
/**
* Adds a module to the list of currently active modules.
*
* @param string $name
* The module name; e.g., 'node'.
* @param string $path
* The module path; e.g., 'core/modules/node'.
*/
public function addModule($name, $path);
/**
* Adds an installation profile to the list of currently active modules.
*
* @param string $name
* The profile name; e.g., 'standard'.
* @param string $path
* The profile path; e.g., 'core/profiles/standard'.
*/
public function addProfile($name, $path);
/**
* Determines which modules require and are required by each module.
*
......
......@@ -290,7 +290,7 @@ public function rebuildThemeData() {
// Defaults to 'twig' (see $defaults above).
$engine = $theme->info['engine'];
if (isset($engines[$engine])) {
$theme->owner = $engines[$engine]->getExtensionPathname();
$theme->owner = $engines[$engine]->uri;
$theme->prefix = $engines[$engine]->getName();
}
......
......@@ -40,8 +40,8 @@ public function __construct(\Twig_LoaderInterface $loader = NULL, $options = arr
// Set twig path namespace for themes and modules.
$namespaces = array();
foreach ($module_handler->getModuleList() as $name => $extension) {
$namespaces[$name] = $extension->getPath();
foreach ($module_handler->getModuleList() as $name => $filename) {
$namespaces[$name] = dirname($filename);
}
foreach ($theme_handler->listInfo() as $name => $extension) {
$namespaces[$name] = $extension->getPath();
......
<?php
/**
* @file
* Provides Config event listeners for testing purposes.
*/
<?php
/**
* @file
* ConfigTest entity integration test module.
*/
<?php
/**
* @file
* Test module which supplies a configuration entity owned by another module.
*/
<?php
/**
* @file
* Provides Config module for testing overrides.
*/
<?php
/**
* @file
* Test module containing a configuration file with an invalid name.
*/
......@@ -68,8 +68,8 @@ public function __construct(CacheBackendInterface $cache_backend, LanguageManage
// Look at all themes and modules.
$directories = array();
foreach ($module_handler->getModuleList() as $name => $module) {
$directories[$name] = $module->getPath();
foreach ($module_handler->getModuleList() as $module => $filename) {
$directories[$module] = dirname($filename);
}
foreach ($theme_handler->listInfo() as $theme) {
$directories[$theme->getName()] = $theme->getPath();
......
<?php
/**
* @file
* Helper module for the Entity Reference tests.
*/
<?php
/**
* @file
* Helper module for the Field API configuration tests.
*/
<?php
/**
* @file
* Helper module for node configuration tests.
*/
<?php
/**
* @file
* Dummy module implementing a search type for search module testing.
*/
<?php
/**
* @file
* Helper module for serialization tests. This file is empty, because all
* implementation is in autoloaded classes.
*/
......@@ -345,21 +345,20 @@ protected function installSchema($module, $tables) {
protected function enableModules(array $modules) {
// Set the list of modules in the extension handler.
$module_handler = $this->container->get('module_handler');
$module_filenames = $module_handler->getModuleList();
// Write directly to active storage to avoid early instantiation of
// the event dispatcher which can prevent modules from registering events.
$active_storage = \Drupal::service('config.storage');
$system_config = $active_storage->read('system.module');
foreach ($modules as $module) {
$module_handler->addModule($module, drupal_get_path('module', $module));
$module_filenames[$module] = drupal_get_filename('module', $module);
// Maintain the list of enabled modules in configuration.
$system_config['enabled'][$module] = 0;
}
$active_storage->write('system.module', $system_config);
$module_handler->setModuleList($module_filenames);
$module_handler->resetImplementations();
// Update the kernel to make their services available.
$module_filenames = $module_handler->getModuleList();
$this->kernel->updateModules($module_filenames, $module_filenames);
// Ensure isLoaded() is TRUE in order to make _theme() work.
......
......@@ -564,7 +564,7 @@ function simpletest_classloader_register() {
$extensions = array();
foreach ($types as $type) {
foreach ($listing->scan($type, TRUE) as $name => $file) {
$extensions[$type][$name] = $file->getPathname();
$extensions[$type][$name] = $file->uri;
}
}
\Drupal::cache()->set($cid, $extensions);
......
......@@ -35,17 +35,17 @@ function testDrupalGetFilename() {
// does not exist.
$this->assertFalse(\Drupal::hasService('keyvalue'), 'The container has no keyvalue service.');
// Retrieving the location of a module.
$this->assertIdentical(drupal_get_filename('module', 'xmlrpc'), 'core/modules/xmlrpc/xmlrpc.info.yml');
$this->assertIdentical(drupal_get_filename('module', 'xmlrpc'), 'core/modules/xmlrpc/xmlrpc.module');
// Retrieving the location of a theme.
$this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml');
$this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.theme');
// Retrieving the location of a theme engine.
$this->assertIdentical(drupal_get_filename('theme_engine', 'phptemplate'), 'core/themes/engines/phptemplate/phptemplate.info.yml');
$this->assertIdentical(drupal_get_filename('theme_engine', 'phptemplate'), 'core/themes/engines/phptemplate/phptemplate.engine');