#overlay=admin/modules on hook_init().
$_SESSION['overlay_enable_redirect'] = 1;
diff --git a/core/modules/php/php.install b/core/modules/php/php.install
index a88fe6a..8acf925 100644
--- a/core/modules/php/php.install
+++ b/core/modules/php/php.install
@@ -6,8 +6,8 @@
*/
/**
- * Implements hook_disable().
+ * Implements hook_uninstall().
*/
-function php_disable() {
+function php_uninstall() {
drupal_set_message(t('The PHP module has been disabled. Any existing content that was using the PHP filter will now be visible in plain text. This might pose a security risk by exposing sensitive information, if any, used in the PHP code.'));
}
diff --git a/core/modules/rest/lib/Drupal/rest/Tests/NodeTest.php b/core/modules/rest/lib/Drupal/rest/Tests/NodeTest.php
index cd453e5..76773df 100644
--- a/core/modules/rest/lib/Drupal/rest/Tests/NodeTest.php
+++ b/core/modules/rest/lib/Drupal/rest/Tests/NodeTest.php
@@ -50,7 +50,7 @@ protected function enableNodeConfiguration($method, $operation) {
*/
public function testNodes() {
// Tests that the node resource works with comment module enabled.
- $this->container->get('module_handler')->enable(array('comment'));
+ $this->container->get('module_handler')->install(array('comment'));
$this->enableNodeConfiguration('GET', 'view');
$node = $this->entityCreate('node');
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
index b55feee..9b40ce5 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
@@ -162,9 +162,9 @@ public function containerBuild(ContainerBuilder $container) {
// away with a simple container holding the absolute bare minimum. When
// a kernel is overridden then there's no need to re-register the keyvalue
// service but when a test is happy with the superminimal container put
- // together here, it still might a keyvalue storage for anything (for
- // eg. module_enable) using \Drupal::state() -- that's why a memory
- // service was added in the first place.
+ // together here, it still might a keyvalue storage for anything using
+ // \Drupal::state() -- that's why a memory service was added in the first
+ // place.
$container
->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueFactory')
->addArgument(new Reference('service_container'));
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
index 505ff33..bd48b1c 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
@@ -89,7 +89,7 @@ function testEnableModulesInstall() {
$this->assertFalse($schema, "'$table' table schema not found.");
// Install the module.
- module_enable(array($module));
+ \Drupal::moduleHandler()->install(array($module));
// Verify that the enabled module exists.
$this->assertTrue(module_exists($module), "$module module found.");
@@ -198,6 +198,9 @@ function testInstallConfig() {
* Tests that the module list is retained after enabling/installing/disabling.
*/
function testEnableModulesFixedList() {
+ // Install system module.
+ $this->container->get('module_handler')->install(array('system'));
+
// entity_test is loaded via $modules; its entity type should exist.
$this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
$this->assertTrue(TRUE == entity_get_info('entity_test'));
@@ -208,12 +211,12 @@ function testEnableModulesFixedList() {
$this->assertTrue(TRUE == entity_get_info('entity_test'));
// Install some other modules; entity_test should still exist.
- module_enable(array('field', 'field_sql_storage', 'field_test'), FALSE);
+ $this->container->get('module_handler')->install(array('field', 'field_sql_storage', 'field_test'), FALSE);
$this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
$this->assertTrue(TRUE == entity_get_info('entity_test'));
- // Disable one of those modules; entity_test should still exist.
- module_disable(array('field_test'));
+ // Uninstall one of those modules; entity_test should still exist.
+ $this->container->get('module_handler')->uninstall(array('field_test'));
$this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
$this->assertTrue(TRUE == entity_get_info('entity_test'));
@@ -222,7 +225,7 @@ function testEnableModulesFixedList() {
$this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
$this->assertTrue(TRUE == entity_get_info('entity_test'));
- // Reactivate the disabled module without enabling it.
+ // Reactivate the previously uninstalled module.
$this->enableModules(array('field_test'));
// Create a field and an instance.
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 7b9302a..cbaf3e0 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -811,7 +811,7 @@ protected function setUp() {
}
if ($modules) {
$modules = array_unique($modules);
- $success = module_enable($modules, TRUE);
+ $success = \Drupal::moduleHandler()->install($modules, TRUE);
$this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
$this->rebuildContainer();
}
diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php
index d674b18..be0ec46 100644
--- a/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php
+++ b/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php
@@ -115,18 +115,11 @@ public function buildForm(array $form, array &$form_state) {
// were not manually selected.
foreach ($this->modules['dependencies'] as $module => $dependencies) {
$items[] = format_plural(count($dependencies), 'You must enable the @required module to install @module.', 'You must enable the @required modules to install @module.', array(
- '@module' => $this->modules['enable'][$module],
+ '@module' => $this->modules['install'][$module],
'@required' => implode(', ', $dependencies),
));
}
- foreach ($this->modules['missing'] as $name => $dependents) {
- $items[] = format_plural(count($dependents), 'The @module module is missing, so the following module will be disabled: @depends.', 'The @module module is missing, so the following modules will be disabled: @depends.', array(
- '@module' => $name,
- '@depends' => implode(', ', $dependents),
- ));
- }
-
$form['message'] = array(
'#theme' => 'item_list',
'#items' => $items,
@@ -146,12 +139,9 @@ public function submitForm(array &$form, array &$form_state) {
// Gets list of modules prior to install process.
$before = $this->moduleHandler->getModuleList();
- // Installs, enables, and disables modules.
- if (!empty($this->modules['enable'])) {
- $this->moduleHandler->enable(array_keys($this->modules['enable']));
- }
- if (!empty($this->modules['disable'])) {
- $this->moduleHandler->disable(array_keys($this->modules['disable']));
+ // Install the given modules.
+ if (!empty($this->modules['install'])) {
+ $this->moduleHandler->install(array_keys($this->modules['install']));
}
// Gets module list after install process, flushes caches and displays a
diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php
index 32d8db7..507df13 100644
--- a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php
+++ b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php
@@ -14,7 +14,7 @@
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
- * Provides module enable/disable interface.
+ * Provides module installation interface.
*
* The list of modules gets populated by module.info.yml files, which contain
* each module's name, description, and information about which modules it
@@ -117,7 +117,7 @@ public function buildForm(array $form, array &$form_state) {
'#title' => $this->t($package),
'#theme' => 'system_modules_details',
'#header' => array(
- array('data' => '' . $this->t('Enabled') . '', 'class' => array('checkbox')),
+ array('data' => '' . $this->t('Installed') . '', 'class' => array('checkbox')),
array('data' => $this->t('Name'), 'class' => array('name')),
array('data' => $this->t('Description'), 'class' => array('description', RESPONSIVE_PRIORITY_LOW)),
),
@@ -206,8 +206,9 @@ protected function buildRow(array $modules, $module, $distribution) {
// Present a checkbox for installing and indicating the status of a module.
$row['enable'] = array(
'#type' => 'checkbox',
- '#title' => $this->t('Enable'),
+ '#title' => $this->t('Install'),
'#default_value' => (bool) $module->status,
+ '#disabled' => (bool) $module->status,
);
// Disable the checkbox for required modules.
@@ -301,67 +302,47 @@ protected function buildRow(array $modules, $module, $distribution) {
}
/**
- * Helper function for building a list of modules to enable or disable.
+ * Helper function for building a list of modules to install.
*
* @param array $form_state
* The form state array.
*
* @return array
- * An array of modules to disable/enable and their dependencies.
+ * An array of modules to install and their dependencies.
*/
protected function buildModuleList(array $form_state) {
$packages = $form_state['values']['modules'];
- // Build a list of modules to enable or disable.
+ // Build a list of modules to install.
$modules = array(
- 'enable' => array(),
- 'disable' => array(),
+ 'install' => array(),
'dependencies' => array(),
- 'missing' => array(),
);
- // Build a list of missing dependencies.
+ // Required modules have to be installed.
// @todo This should really not be handled here.
$data = system_rebuild_module_data();
foreach ($data as $name => $module) {
- // Modules with missing dependencies have to be disabled.
- if ($this->moduleHandler->moduleExists($name)) {
- foreach (array_keys($module->requires) as $dependency) {
- if (!isset($data[$dependency])) {
- $modules['missing'][$dependency][$name] = $module->info['name'];
- $modules['disable'][$name] = $module->info['name'];
- }
- }
- }
- elseif (!empty($module->required)) {
- $modules['enable'][$name] = $module->info['name'];
+ if (!empty($module->required) && !$this->moduleHandler->moduleExists($name)) {
+ $modules['install'][$name] = $module->info['name'];
}
}
// First, build a list of all modules that were selected.
foreach ($packages as $items) {
foreach ($items as $name => $checkbox) {
- // Do not override modules that are forced to be enabled/disabled.
- if (isset($modules['enable'][$name]) || isset($modules['disable'][$name])) {
- continue;
- }
-
- $enabled = $this->moduleHandler->moduleExists($name);
- if (!$checkbox['enable'] && $enabled) {
- $modules['disable'][$name] = $data[$name]->info['name'];
- }
- elseif ($checkbox['enable'] && !$enabled) {
- $modules['enable'][$name] = $data[$name]->info['name'];
+ if ($checkbox['enable'] && !$this->moduleHandler->moduleExists($name)) {
+ $modules['install'][$name] = $data[$name]->info['name'];
}
}
}
// Add all dependencies to a list.
- while (list($module) = each($modules['enable'])) {
+ while (list($module) = each($modules['install'])) {
foreach (array_keys($data[$module]->requires) as $dependency) {
- if (!isset($modules['enable'][$dependency]) && !$this->moduleHandler->moduleExists($dependency)) {
+ if (!isset($modules['install'][$dependency]) && !$this->moduleHandler->moduleExists($dependency)) {
$modules['dependencies'][$module][$dependency] = $data[$dependency]->info['name'];
- $modules['enable'][$dependency] = $data[$dependency]->info['name'];
+ $modules['install'][$dependency] = $data[$dependency]->info['name'];
}
}
}
@@ -371,11 +352,11 @@ protected function buildModuleList(array $form_state) {
// Invoke hook_requirements('install'). If failures are detected, make
// sure the dependent modules aren't installed either.
- foreach (array_keys($modules['enable']) as $module) {
- if (drupal_get_installed_schema_version($module) == SCHEMA_UNINSTALLED && !drupal_check_module($module)) {
- unset($modules['enable'][$module]);
+ foreach (array_keys($modules['install']) as $module) {
+ if (!drupal_check_module($module)) {
+ unset($modules['install'][$module]);
foreach (array_keys($data[$module]->required_by) as $dependent) {
- unset($modules['enable'][$dependent]);
+ unset($modules['install'][$dependent]);
unset($modules['dependencies'][$dependent]);
}
}
@@ -388,11 +369,12 @@ protected function buildModuleList(array $form_state) {
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
- // Retrieve a list of modules to enable/disable and their dependencies.
+ // Retrieve a list of modules to install and their dependencies.
$modules = $this->buildModuleList($form_state);
- // Check if we have to enable any dependencies. If there is one or more
- // dependencies that are not enabled yet, redirect to the confirmation form.
+ // Check if we have to install any dependencies. If there is one or more
+ // dependencies that are not installed yet, redirect to the confirmation
+ // form.
if (!empty($modules['dependencies']) || !empty($modules['missing'])) {
// Write the list of changed module states into a key value store.
$account = $this->getCurrentUser()->id();
@@ -410,11 +392,8 @@ public function submitForm(array &$form, array &$form_state) {
$before = $this->moduleHandler->getModuleList();
// There seem to be no dependencies that would need approval.
- if (!empty($modules['enable'])) {
- $this->moduleHandler->enable(array_keys($modules['enable']));
- }
- if (!empty($modules['disable'])) {
- $this->moduleHandler->disable(array_keys($modules['disable']));
+ if (!empty($modules['install'])) {
+ $this->moduleHandler->install(array_keys($modules['install']));
}
// Gets module list after install process, flushes caches and displays a
diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php
index 33e402b..af1fb21 100644
--- a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php
+++ b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php
@@ -70,15 +70,15 @@ public function buildForm(array $form, array &$form_state) {
// Get a list of disabled, installed modules.
$modules = system_rebuild_module_data();
- $disabled = array_filter($modules, function ($module) {
- return empty($module->status) && drupal_get_installed_schema_version($module->name) > SCHEMA_UNINSTALLED;
+ $uninstallable = array_filter($modules, function ($module) use ($modules) {
+ return empty($modules[$module->name]->info['required']) && drupal_get_installed_schema_version($module->name) > SCHEMA_UNINSTALLED;
});
$form['modules'] = array();
// Only build the rest of the form if there are any modules available to
// uninstall;
- if (empty($disabled)) {
+ if (empty($uninstallable)) {
return $form;
}
@@ -86,10 +86,10 @@ public function buildForm(array $form, array &$form_state) {
// Sort all modules by their name.
$this->moduleHandler->loadInclude('system', 'inc', 'system.admin');
- uasort($disabled, 'system_sort_modules_by_info_name');
+ uasort($uninstallable, 'system_sort_modules_by_info_name');
$form['uninstall'] = array('#tree' => TRUE);
- foreach ($disabled as $module) {
+ foreach ($uninstallable as $module) {
$name = $module->info['name'] ?: $module->name;
$form['modules'][$module->name]['#module_name'] = $name;
$form['modules'][$module->name]['name']['#markup'] = $name;
@@ -107,7 +107,7 @@ public function buildForm(array $form, array &$form_state) {
foreach (array_keys($module->required_by) as $dependent) {
if ($dependent != $profile && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) {
$name = isset($modules[$dependent]->info['name']) ? $modules[$dependent]->info['name'] : $dependent;
- $form['modules'][$module->name]['#dependents'][] = $name;
+ $form['modules'][$module->name]['#required_by'][] = $name;
$form['uninstall'][$module->name]['#disabled'] = TRUE;
}
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php
index cf7d9cf..4e45336 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php
@@ -26,7 +26,7 @@ public static function getInfo() {
* Ensures entity info cache is updated after changes.
*/
function testEntityInfoChanges() {
- module_enable(array('entity_cache_test'));
+ \Drupal::moduleHandler()->install(array('entity_cache_test'));
$entity_info = entity_get_info();
$this->assertTrue(isset($entity_info['entity_cache_test']), 'Test entity type found.');
@@ -39,8 +39,8 @@ function testEntityInfoChanges() {
$info = entity_get_info('entity_cache_test');
$this->assertEqual($info['label'], 'New label.', 'New label appears in entity info.');
- // Disable the providing module and make sure the entity type is gone.
- module_disable(array('entity_cache_test', 'entity_cache_test_dependency'));
+ // Uninstall the providing module and make sure the entity type is gone.
+ module_uninstall(array('entity_cache_test', 'entity_cache_test_dependency'));
$entity_info = entity_get_info();
$this->assertFalse(isset($entity_info['entity_cache_test']), 'Entity type of the providing module is gone.');
}
@@ -51,7 +51,7 @@ function testEntityInfoChanges() {
* @see entity_cache_test_watchdog()
*/
function testEntityInfoCacheWatchdog() {
- module_enable(array('entity_cache_test'));
+ \Drupal::moduleHandler()->install(array('entity_cache_test'));
$info = \Drupal::state()->get('entity_cache_test');
$this->assertEqual($info['label'], 'Entity Cache Test', 'Entity info label is correct.');
$this->assertEqual($info['controllers']['storage'], 'Drupal\Core\Entity\DatabaseStorageController', 'Entity controller class info is correct.');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php
index 2705aed..e3510f6 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php
@@ -75,7 +75,7 @@ function testLanguageSelectElementOptions() {
function testHiddenLanguageSelectElement() {
// Disable the language module, so that the language select field will not
// be rendered.
- module_disable(array('language'));
+ module_uninstall(array('language'));
$this->drupalGet('form-test/language_select');
// Check that the language fields were rendered on the page.
$ids = array('edit-languages-all', 'edit-languages-configurable', 'edit-languages-locked', 'edit-languages-config-and-locked');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php
index 2fd8eb9..71f29d4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php
@@ -34,7 +34,7 @@ public static function getInfo() {
*/
function testClassLoading() {
// Enable the module_test and module_autoload_test modules.
- module_enable(array('module_test', 'module_autoload_test'), FALSE);
+ \Drupal::moduleHandler()->install(array('module_test', 'module_autoload_test'), FALSE);
$this->resetAll();
// Check twice to test an unprimed and primed system_list() cache.
for ($i=0; $i<2; $i++) {
@@ -50,7 +50,7 @@ function testClassLoading() {
*/
function testClassLoadingDisabledModules() {
// Ensure that module_autoload_test is disabled.
- module_disable(array('module_autoload_test'), FALSE);
+ module_uninstall(array('module_autoload_test'), FALSE);
$this->resetAll();
// Check twice to test an unprimed and primed system_list() cache.
for ($i=0; $i<2; $i++) {
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php
index 59dc6a2..83030e1 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php
@@ -54,20 +54,6 @@ function testMissingModules() {
$this->assertRaw(t('@module (missing)', array('@module' => drupal_ucfirst('_missing_dependency'))), 'A module with missing dependencies is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[Testing][system_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
-
- // Force enable the system_dependencies_test module.
- module_enable(array('system_dependencies_test'), FALSE);
-
- // Verify that the module is forced to be disabled when submitting
- // the module page.
- $this->drupalPost('admin/modules', array(), t('Save configuration'));
- $this->assertText(t('The @module module is missing, so the following module will be disabled: @depends.', array('@module' => '_missing_dependency', '@depends' => 'System dependency test')), 'The module missing dependencies will be disabled.');
-
- // Confirm.
- $this->drupalPost(NULL, NULL, t('Continue'));
-
- // Verify that the module has been disabled.
- $this->assertModules(array('system_dependencies_test'), FALSE);
}
/**
@@ -103,7 +89,7 @@ function testIncompatibleCoreVersionDependency() {
* Tests enabling a module that depends on a module which fails hook_requirements().
*/
function testEnableRequirementsFailureDependency() {
- module_enable(array('comment'));
+ \Drupal::moduleHandler()->install(array('comment'));
$this->assertModules(array('requirements1_test'), FALSE);
$this->assertModules(array('requirements2_test'), FALSE);
@@ -130,7 +116,7 @@ function testEnableRequirementsFailureDependency() {
* UI. Dependencies should be enabled before their dependents.
*/
function testModuleEnableOrder() {
- module_enable(array('module_test'), FALSE);
+ \Drupal::moduleHandler()->install(array('module_test'), FALSE);
$this->resetAll();
$this->assertModules(array('module_test'), TRUE);
\Drupal::state()->set('module_test.dependency', 'dependency');
@@ -161,7 +147,7 @@ function testModuleEnableOrder() {
$this->assertModules(array('forum', 'ban', 'php', 'datetime', 'comment', 'history', 'taxonomy', 'options', 'number'), TRUE);
// Check the actual order which is saved by module_test_modules_enabled().
- $module_order = \Drupal::state()->get('system_test.module_enable_order') ?: array();
+ $module_order = \Drupal::state()->get('module_test.install_order') ?: array();
$this->assertIdentical($module_order, $expected_order);
}
@@ -175,14 +161,6 @@ function testUninstallDependents() {
$this->drupalPost(NULL, array(), t('Continue'));
$this->assertModules(array('forum'), TRUE);
- // Disable forum and comment. Both should now be installed but disabled.
- $edit = array('modules[Core][forum][enable]' => FALSE);
- $this->drupalPost('admin/modules', $edit, t('Save configuration'));
- $this->assertModules(array('forum'), FALSE);
- $edit = array('modules[Core][comment][enable]' => FALSE);
- $this->drupalPost('admin/modules', $edit, t('Save configuration'));
- $this->assertModules(array('comment'), FALSE);
-
// Check that the taxonomy module cannot be uninstalled.
$this->drupalGet('admin/modules/uninstall');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="uninstall[comment]"]');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
deleted file mode 100644
index 8458bc7..0000000
--- a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
+++ /dev/null
@@ -1,226 +0,0 @@
- 'Enable/disable modules',
- 'description' => 'Enable/disable core module and confirm table creation/deletion.',
- 'group' => 'Module',
- );
- }
-
- /**
- * Tests that all core modules can be enabled, disabled and uninstalled.
- */
- function testEnableDisable() {
- $modules = system_rebuild_module_data();
- foreach ($modules as $name => $module) {
- // Filters all modules under core directory.
- $in_core_path = (strpos($module->uri, 'core/modules') === 0);
- // Filters test modules under Testing package.
- $in_testing_package = ($module->info['package'] == 'Testing');
- // Try to enable, disable and uninstall all core modules, unless they are
- // hidden or required or system test modules.
- if (!$in_core_path || !empty($module->info['hidden']) || !empty($module->info['required']) || $in_testing_package) {
- unset($modules[$name]);
- }
- }
-
- // Throughout this test, some modules may be automatically enabled (due to
- // dependencies). We'll keep track of them in an array, so we can handle
- // them separately.
- $automatically_enabled = array();
-
- // Remove already enabled modules (via installation profile).
- // @todo Remove this after removing all dependencies from Testing profile.
- foreach ($this->container->get('module_handler')->getModuleList() as $dependency => $filename) {
- // Exclude required modules. Only installation profile "suggestions" can
- // be disabled and uninstalled.
- if (isset($modules[$dependency])) {
- $automatically_enabled[$dependency] = TRUE;
- }
- }
-
- $this->assertTrue(count($modules), format_string('Found @count modules that can be enabled: %modules', array(
- '@count' => count($modules),
- '%modules' => implode(', ', array_keys($modules)),
- )));
-
- // Enable the dblog module first, since we will be asserting the presence
- // of log messages throughout the test.
- if (isset($modules['dblog'])) {
- $modules = array('dblog' => $modules['dblog']) + $modules;
- }
-
- // Set a variable so that the hook implementations in system_test.module
- // will display messages via drupal_set_message().
- \Drupal::state()->set('system_test.verbose_module_hooks', TRUE);
-
- // Go through each module in the list and try to enable it (unless it was
- // already enabled automatically due to a dependency).
- foreach ($modules as $name => $module) {
- if (empty($automatically_enabled[$name])) {
- // Start a list of modules that we expect to be enabled this time.
- $modules_to_enable = array($name);
-
- // Find out if the module has any dependencies that aren't enabled yet;
- // if so, add them to the list of modules we expect to be automatically
- // enabled.
- foreach (array_keys($module->requires) as $dependency) {
- if (isset($modules[$dependency]) && empty($automatically_enabled[$dependency])) {
- $modules_to_enable[] = $dependency;
- $automatically_enabled[$dependency] = TRUE;
- }
- }
-
- // Check that each module is not yet enabled and does not have any
- // database tables yet.
- foreach ($modules_to_enable as $module_to_enable) {
- $this->assertModules(array($module_to_enable), FALSE);
- $this->assertModuleTablesDoNotExist($module_to_enable);
- }
-
- // Install and enable the module.
- $edit = array();
- $package = $module->info['package'];
- $edit['modules[' . $package . '][' . $name . '][enable]'] = $name;
- $this->drupalPost('admin/modules', $edit, t('Save configuration'));
- // Handle the case where modules were installed along with this one and
- // where we therefore hit a confirmation screen.
- if (count($modules_to_enable) > 1) {
- $this->drupalPost(NULL, array(), t('Continue'));
- }
- $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
-
- // Check that hook_modules_installed() and hook_modules_enabled() were
- // invoked with the expected list of modules, that each module's
- // database tables now exist, and that appropriate messages appear in
- // the logs.
- foreach ($modules_to_enable as $module_to_enable) {
- $this->assertText(t('hook_modules_installed fired for @module', array('@module' => $module_to_enable)));
- $this->assertText(t('hook_modules_enabled fired for @module', array('@module' => $module_to_enable)));
- $this->assertModules(array($module_to_enable), TRUE);
- $this->assertModuleTablesExist($module_to_enable);
- $this->assertModuleConfig($module_to_enable);
- $this->assertLogMessage('system', "%module module installed.", array('%module' => $module_to_enable), WATCHDOG_INFO);
- $this->assertLogMessage('system', "%module module enabled.", array('%module' => $module_to_enable), WATCHDOG_INFO);
- }
-
- // Disable and uninstall the original module, and check appropriate
- // hooks, tables, and log messages. (Later, we'll go back and do the
- // same thing for modules that were enabled automatically.) Skip this
- // for the dblog module, because that is needed for the test; we'll go
- // back and do that one at the end also.
- if ($name != 'dblog') {
- $this->assertSuccessfulDisableAndUninstall($name, $package);
- }
- }
- }
-
- // Go through all modules that were automatically enabled, and try to
- // disable and uninstall them one by one.
- while (!empty($automatically_enabled)) {
- $initial_count = count($automatically_enabled);
- foreach (array_keys($automatically_enabled) as $name) {
- $module = $modules[$name];
- $package = $module->info['package'];
- // If the module can't be disabled due to dependencies, skip it and try
- // again the next time. Otherwise, try to disable it.
- $this->drupalGet('admin/modules');
- $disabled_checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[' . $package . '][' . $name . '][enable]"]');
- if (empty($disabled_checkbox) && $name != 'dblog') {
- unset($automatically_enabled[$name]);
- $this->assertSuccessfulDisableAndUninstall($name, $package);
- }
- }
- $final_count = count($automatically_enabled);
- // If all checkboxes were disabled, something is really wrong with the
- // test. Throw a failure and avoid an infinite loop.
- if ($initial_count == $final_count) {
- $this->fail(t('Remaining modules could not be disabled.'));
- break;
- }
- }
-
- // Disable and uninstall the dblog module last, since we needed it for
- // assertions in all the above tests.
- if (isset($modules['dblog'])) {
- $this->assertSuccessfulDisableAndUninstall('dblog');
- }
-
- // Now that all modules have been tested, go back and try to enable them
- // all again at once. This tests two things:
- // - That each module can be successfully enabled again after being
- // uninstalled.
- // - That enabling more than one module at the same time does not lead to
- // any errors.
- $edit = array();
- foreach ($modules as $name => $module) {
- $edit['modules[' . $module->info['package'] . '][' . $name . '][enable]'] = $name;
- }
- $this->drupalPost('admin/modules', $edit, t('Save configuration'));
- $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
- }
-
- /**
- * Disables and uninstalls a module and asserts that it was done correctly.
- *
- * @param string $module
- * The name of the module to disable and uninstall.
- * @param string $package
- * (optional) The package of the module to disable and uninstall. Defaults
- * to 'Core'.
- */
- function assertSuccessfulDisableAndUninstall($module, $package = 'Core') {
- // Disable the module.
- $edit = array();
- $edit['modules[' . $package . '][' . $module . '][enable]'] = FALSE;
- $this->drupalPost('admin/modules', $edit, t('Save configuration'));
- $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
- $this->assertModules(array($module), FALSE);
-
- // Check that the appropriate hook was fired and the appropriate log
- // message appears.
- $this->assertText(t('hook_modules_disabled fired for @module', array('@module' => $module)));
- if ($module != 'dblog') {
- $this->assertLogMessage('system', "%module module disabled.", array('%module' => $module), WATCHDOG_INFO);
- }
-
- // Check that the module's database tables still exist.
- $this->assertModuleTablesExist($module);
- // Check that the module's config files still exist.
- $this->assertModuleConfig($module);
-
- // Uninstall the module.
- $edit = array();
- $edit['uninstall[' . $module . ']'] = $module;
- $this->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
- $this->drupalPost(NULL, NULL, t('Uninstall'));
- $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
- $this->assertModules(array($module), FALSE);
-
- // Check that the appropriate hook was fired and the appropriate log
- // message appears. (But don't check for the log message if the dblog
- // module was just uninstalled, since the {watchdog} table won't be there
- // anymore.)
- $this->assertText(t('hook_modules_uninstalled fired for @module', array('@module' => $module)));
- if ($module != 'dblog') {
- $this->assertLogMessage('system', "%module module uninstalled.", array('%module' => $module), WATCHDOG_INFO);
- }
-
- // Check that the module's database tables no longer exist.
- $this->assertModuleTablesDoNotExist($module);
- // Check that the module's config files no longer exist.
- $this->assertNoModuleConfig($module);
- }
-}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/InstallTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/InstallTest.php
index a141f00..91fe4ef 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/InstallTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/InstallTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Module;
+use Drupal\Core\Extension\ExtensionNameLengthException;
use Drupal\simpletest\WebTestBase;
/**
@@ -46,6 +47,53 @@ function testDrupalWriteRecord() {
// 'module_test' module was being installed and enabled.
$data = db_query("SELECT data FROM {module_test}")->fetchCol();
$this->assertTrue(in_array('Data inserted in hook_install()', $data), 'Data inserted using drupal_write_record() in hook_install() is correctly saved.');
- $this->assertTrue(in_array('Data inserted in hook_enable()', $data), 'Data inserted using drupal_write_record() in hook_enable() is correctly saved.');
}
+
+ /**
+ * Tests enabling User module once more.
+ *
+ * Regression: The installer might enable a module twice due to automatic
+ * dependency resolution. A bug caused the stored weight for User module to
+ * be an array.
+ */
+ function testEnableUserTwice() {
+ \Drupal::moduleHandler()->install(array('user'), FALSE);
+ $this->assertIdentical(config('system.module')->get('enabled.user'), '0');
+ }
+
+ /**
+ * Tests recorded schema versions of early installed modules in the installer.
+ */
+ function testRequiredModuleSchemaVersions() {
+ $version = drupal_get_installed_schema_version('system', TRUE);
+ $this->assertTrue($version > 0, 'System module version is > 0.');
+ $version = drupal_get_installed_schema_version('user', TRUE);
+ $this->assertTrue($version > 0, 'User module version is > 0.');
+ }
+
+ /**
+ * Tests that an exception is thrown when a module name is too long.
+ */
+ function testModuleNameLength() {
+ $module_name = 'invalid_module_name_over_the_maximum_allowed_character_length';
+ $message = format_string('Exception thrown when enabling module %name with a name length over the allowed maximum', array('%name' => $module_name));
+ try {
+ $this->container->get('module_handler')->install(array($module_name));
+ $this->fail($message);
+ }
+ catch (ExtensionNameLengthException $e) {
+ $this->pass($message);
+ }
+
+ // Since for the UI, the submit callback uses FALSE, test that too.
+ $message = format_string('Exception thrown when enabling as if via the UI the module %name with a name length over the allowed maximum', array('%name' => $module_name));
+ try {
+ $this->container->get('module_handler')->install(array($module_name), FALSE);
+ $this->fail($message);
+ }
+ catch (ExtensionNameLengthException $e) {
+ $this->pass($message);
+ }
+ }
+
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/InstallUninstallTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/InstallUninstallTest.php
new file mode 100644
index 0000000..76889b0
--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/InstallUninstallTest.php
@@ -0,0 +1,180 @@
+ 'Install/uninstall modules',
+ 'description' => 'Install/uninstall core module and confirm table creation/deletion.',
+ 'group' => 'Module',
+ );
+ }
+
+ /**
+ * Tests that a fixed set of modules can be installed and uninstalled.
+ */
+ public function testInstallUninstall() {
+ // Set a variable so that the hook implementations in system_test.module
+ // will display messages via drupal_set_message().
+ $this->container->get('state')->set('system_test.verbose_module_hooks', TRUE);
+
+ // Try to install and uninstall book, toolbar modules and its dependencies.
+ $all_modules = system_rebuild_module_data();
+
+ $all_modules = array_filter($all_modules, function ($module) {
+ // Filter hidden, required and already enabled modules.
+ if (!empty($module->info['hidden']) || !empty($module->info['required']) || $module->status == TRUE) {
+ return FALSE;
+ }
+ return TRUE;
+ });
+
+ foreach (array('book', 'ckeditor', 'toolbar') as $name) {
+ $modules[$name] = $all_modules[$name];
+ foreach ($modules[$name]->requires as $dependency) {
+ if (isset($all_modules[$dependency['name']])) {
+ $modules[$dependency['name']] = $all_modules[$dependency['name']];
+ }
+ }
+ }
+
+ // Go through each module in the list and try to install it (unless it was
+ // already installed automatically due to a dependency).
+ $automatically_installed = array();
+ while (list($name, $module) = each($modules)) {
+ // Skip modules that have been automatically installed.
+ if (in_array($name, $automatically_installed)) {
+ continue;
+ }
+
+ // Start a list of modules that we expect to be installed this time.
+ $modules_to_install = array($name);
+ foreach (array_keys($module->requires) as $dependency) {
+ if (isset($modules[$dependency]) && !in_array($dependency, $automatically_installed)) {
+ $modules_to_install[] = $dependency;
+
+ // Add any potential dependency of this module to the list of modules we
+ // expect to be automatically installed.
+ $automatically_installed[] = $dependency;
+ }
+ }
+
+ // Check that each module is not yet enabled and does not have any
+ // database tables yet.
+ foreach ($modules_to_install as $module_to_install) {
+ $this->assertModules(array($module_to_install), FALSE);
+ $this->assertModuleTablesDoNotExist($module_to_install);
+ }
+
+ // Install the module.
+ $edit = array();
+ $package = $module->info['package'];
+ $edit["modules[$package][$name][enable]"] = TRUE;
+ $this->drupalPost('admin/modules', $edit, t('Save configuration'));
+
+ // Handle the case where modules were installed along with this one and
+ // where we therefore hit a confirmation screen.
+ if (count($modules_to_install) > 1) {
+ $this->drupalPost(NULL, array(), t('Continue'));
+ }
+
+ $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
+
+ // Check that hook_modules_installed() was invoked with the expected list
+ // of modules, that each module's database tables now exist, and that
+ // appropriate messages appear in the logs.
+ foreach ($modules_to_install as $module_to_install) {
+ $this->assertText(t('hook_modules_installed fired for @module', array('@module' => $module_to_install)));
+ $this->assertModules(array($module_to_install), TRUE);
+ $this->assertModuleTablesExist($module_to_install);
+ $this->assertModuleConfig($module_to_install);
+ $this->assertLogMessage('system', "%module module installed.", array('%module' => $module_to_install), WATCHDOG_INFO);
+ }
+
+ // Uninstall the original module, and check appropriate
+ // hooks, tables, and log messages. (Later, we'll go back and do the
+ // same thing for modules that were enabled automatically.)
+ $this->assertSuccessfullUninstall($name, $package);
+ }
+
+ // Go through all modules that were automatically installed, and try to
+ // uninstall them one by one.
+ while ($automatically_installed) {
+ $initial_count = count($automatically_installed);
+ foreach ($automatically_installed as $name) {
+ $package = $modules[$name]->info['package'];
+ // If the module can't be uninstalled due to dependencies, skip it and
+ // try again the next time. Otherwise, try to uninstall it.
+ $this->drupalGet('admin/modules/uninstall');
+ $disabled_checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="uninstall[' . $name . ']"]');
+ if (empty($disabled_checkbox)) {
+ $automatically_installed = array_diff($automatically_installed, array($name));
+ $this->assertSuccessfullUninstall($name, $package);
+ }
+ }
+ $final_count = count($automatically_installed);
+ // If all checkboxes were disabled, something is really wrong with the
+ // test. Throw a failure and avoid an infinite loop.
+ if ($initial_count == $final_count) {
+ $this->fail('Remaining modules could not be disabled.');
+ break;
+ }
+ }
+
+ // Now that all modules have been tested, go back and try to enable them
+ // all again at once. This tests two things:
+ // - That each module can be successfully enabled again after being
+ // uninstalled.
+ // - That enabling more than one module at the same time does not lead to
+ // any errors.
+ $edit = array();
+ foreach ($modules as $name => $module) {
+ $edit['modules[' . $module->info['package'] . '][' . $name . '][enable]'] = TRUE;
+ }
+ $this->drupalPost('admin/modules', $edit, t('Save configuration'));
+ $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
+ }
+
+ /**
+ * Uninstalls a module and asserts that it was done correctly.
+ *
+ * @param string $module
+ * The name of the module to uninstall.
+ * @param string $package
+ * (optional) The package of the module to uninstall. Defaults
+ * to 'Core'.
+ */
+ protected function assertSuccessfullUninstall($module, $package = 'Core') {
+ $edit = array();
+ $edit['uninstall[' . $module . ']'] = TRUE;
+ $this->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
+ $this->drupalPost(NULL, NULL, t('Uninstall'));
+ $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
+ $this->assertModules(array($module), FALSE);
+
+ // Check that the appropriate hook was fired and the appropriate log
+ // message appears. (But don't check for the log message if the dblog
+ // module was just uninstalled, since the {watchdog} table won't be there
+ // anymore.)
+ $this->assertText(t('hook_modules_uninstalled fired for @module', array('@module' => $module)));
+ $this->assertLogMessage('system', "%module module uninstalled.", array('%module' => $module), WATCHDOG_INFO);
+
+ // Check that the module's database tables no longer exist.
+ $this->assertModuleTablesDoNotExist($module);
+ // Check that the module's config files no longer exist.
+ $this->assertNoModuleConfig($module);
+ }
+
+}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
index d2d65bc..ee303e4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
@@ -43,7 +43,7 @@ function testModuleList() {
$this->assertModuleList($module_list, t('Standard profile'));
// Try to install a new module.
- module_enable(array('ban'));
+ \Drupal::moduleHandler()->install(array('ban'));
$module_list[] = 'ban';
sort($module_list);
$this->assertModuleList($module_list, t('After adding a module'));
@@ -98,18 +98,18 @@ function testModuleImplements() {
$this->assertTrue(cache('bootstrap')->get('module_implements'), 'The module implements cache is populated after requesting a page.');
// Prime ModuleHandler's hook implementation cache by invoking a random hook
- // name. The subsequent module_enable() below will only call into
- // setModuleList(), but will not explicitly reset the hook implementation
- // cache, as that is expected to happen implicitly by setting the module
- // list. This verifies that the hook implementation cache is cleared
- // whenever setModuleList() is called.
+ // name. The subsequent \Drupal\Core\Extension\ModuleHandler::install()
+ // below will only call into setModuleList(), but will not explicitly reset
+ // the hook implementation cache, as that is expected to happen implicitly
+ // by setting the module list. This verifies that the hook implementation
+ // cache is cleared whenever setModuleList() is called.
$module_handler = \Drupal::moduleHandler();
$module_handler->invokeAll('test');
// Make sure group include files are detected properly even when the file is
// already loaded when the cache is rebuilt.
// For that activate the module_test which provides the file to load.
- module_enable(array('module_test'));
+ \Drupal::moduleHandler()->install(array('module_test'));
$module_handler->loadAll();
module_load_include('inc', 'module_test', 'module_test.file');
$modules = $module_handler->getImplementations('test_hook');
@@ -120,7 +120,7 @@ function testModuleImplements() {
* Test that module_invoke() can load a hook defined in hook_hook_info().
*/
function testModuleInvoke() {
- module_enable(array('module_test'), FALSE);
+ \Drupal::moduleHandler()->install(array('module_test'), FALSE);
$this->resetAll();
$this->drupalGet('module-test/hook-dynamic-loading-invoke');
$this->assertText('success!', 'module_invoke() dynamically loads a hook defined in hook_hook_info().');
@@ -130,7 +130,7 @@ function testModuleInvoke() {
* Test that module_invoke_all() can load a hook defined in hook_hook_info().
*/
function testModuleInvokeAll() {
- module_enable(array('module_test'), FALSE);
+ \Drupal::moduleHandler()->install(array('module_test'), FALSE);
$this->resetAll();
$this->drupalGet('module-test/hook-dynamic-loading-invoke-all');
$this->assertText('success!', 'module_invoke_all() dynamically loads a hook defined in hook_hook_info().');
@@ -143,7 +143,7 @@ function testModuleInvokeAll() {
* functions execute early in the request handling.
*/
function testModuleInvokeAllDuringLoadFunction() {
- module_enable(array('module_test'), FALSE);
+ \Drupal::moduleHandler()->install(array('module_test'), FALSE);
$this->resetAll();
$this->drupalGet('module-test/hook-dynamic-loading-invoke-all-during-load/module_test');
$this->assertText('success!', 'Menu item load function invokes a hook defined in hook_hook_info().');
@@ -156,7 +156,7 @@ function testDependencyResolution() {
// Enable the test module, and make sure that other modules we are testing
// are not already enabled. (If they were, the tests below would not work
// correctly.)
- module_enable(array('module_test'), FALSE);
+ \Drupal::moduleHandler()->install(array('module_test'), FALSE);
$this->assertTrue(module_exists('module_test'), 'Test module is enabled.');
$this->assertFalse(module_exists('forum'), 'Forum module is disabled.');
$this->assertFalse(module_exists('ban'), 'Ban module is disabled.');
@@ -166,53 +166,24 @@ function testDependencyResolution() {
// depends on a made-up module, foo. Nothing should be installed.
\Drupal::state()->set('module_test.dependency', 'missing dependency');
drupal_static_reset('system_rebuild_module_data');
- $result = module_enable(array('forum'));
- $this->assertFalse($result, 'module_enable() returns FALSE if dependencies are missing.');
- $this->assertFalse(module_exists('forum'), 'module_enable() aborts if dependencies are missing.');
+ $result = \Drupal::moduleHandler()->install(array('forum'));
+ $this->assertFalse($result, '\Drupal\Core\Extension\ModuleHandler::install() returns FALSE if dependencies are missing.');
+ $this->assertFalse(module_exists('forum'), '\Drupal\Core\Extension\ModuleHandler::install() aborts if dependencies are missing.');
// Now, fix the missing dependency. Forum module depends on ban, but ban
- // depends on the PHP module. module_enable() should work.
+ // depends on the PHP module.
+ // \Drupal\Core\Extension\ModuleHandler::install() should work.
\Drupal::state()->set('module_test.dependency', 'dependency');
drupal_static_reset('system_rebuild_module_data');
- $result = module_enable(array('forum'));
- $this->assertTrue($result, 'module_enable() returns the correct value.');
+ $result = \Drupal::moduleHandler()->install(array('forum'));
+ $this->assertTrue($result, '\Drupal\Core\Extension\ModuleHandler::install() returns the correct value.');
// Verify that the fake dependency chain was installed.
- $this->assertTrue(module_exists('ban') && module_exists('php'), 'Dependency chain was installed by module_enable().');
+ $this->assertTrue(module_exists('ban') && module_exists('php'), 'Dependency chain was installed by \Drupal\Core\Extension\ModuleHandler::install().');
// Verify that the original module was installed.
$this->assertTrue(module_exists('forum'), 'Module installation with unlisted dependencies succeeded.');
// Finally, verify that the modules were enabled in the correct order.
- $module_order = \Drupal::state()->get('system_test.module_enable_order') ?: array();
- $this->assertEqual($module_order, array('php', 'ban', 'forum'), 'Modules were enabled in the correct order by module_enable().');
-
- // Now, disable the PHP module. Both forum and ban should be disabled as
- // well, in the correct order.
- module_disable(array('php'));
- $this->assertTrue(!module_exists('forum') && !module_exists('ban'), 'Depedency chain was disabled by module_disable().');
- $this->assertFalse(module_exists('php'), 'Disabling a module with unlisted dependents succeeded.');
- $disabled_modules = \Drupal::state()->get('module_test.disable_order') ?: array();
- $this->assertEqual($disabled_modules, array('forum', 'ban', 'php'), 'Modules were disabled in the correct order by module_disable().');
-
- // Disable a module that is listed as a dependency by the installation
- // profile. Make sure that the profile itself is not on the list of
- // dependent modules to be disabled.
- $profile = drupal_get_profile();
- $info = install_profile_info($profile);
- $this->assertTrue(in_array('comment', $info['dependencies']), 'Comment module is listed as a dependency of the installation profile.');
- $this->assertTrue(module_exists('comment'), 'Comment module is enabled.');
- module_disable(array('comment'));
- $this->assertFalse(module_exists('comment'), 'Comment module was disabled.');
- $disabled_modules = \Drupal::state()->get('module_test.disable_order') ?: array();
- $this->assertTrue(in_array('comment', $disabled_modules), 'Comment module is in the list of disabled modules.');
- $this->assertFalse(in_array($profile, $disabled_modules), 'The installation profile is not in the list of disabled modules.');
-
- // Try to uninstall the PHP module by itself. This should be rejected,
- // since the modules which it depends on need to be uninstalled first, and
- // that is too destructive to perform automatically.
- $result = module_uninstall(array('php'));
- $this->assertFalse($result, 'Calling module_uninstall() on a module whose dependents are not uninstalled fails.');
- foreach (array('forum', 'ban', 'php') as $module) {
- $this->assertNotEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, format_string('The @module module was not uninstalled.', array('@module' => $module)));
- }
+ $module_order = \Drupal::state()->get('module_test.install_order') ?: array();
+ $this->assertEqual($module_order, array('php', 'ban', 'forum'), 'Modules were enabled in the correct order by \Drupal\Core\Extension\ModuleHandler::install().');
// Now uninstall all three modules explicitly, but in the incorrect order,
// and make sure that drupal_uninstal_modules() uninstalled them in the
@@ -232,28 +203,28 @@ function testDependencyResolution() {
$this->assertEqual(drupal_get_installed_schema_version('comment'), SCHEMA_UNINSTALLED, 'Comment module was uninstalled.');
$uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array();
$this->assertTrue(in_array('comment', $uninstalled_modules), 'Comment module is in the list of uninstalled modules.');
- $this->assertFalse(in_array($profile, $uninstalled_modules), 'The installation profile is not in the list of uninstalled modules.');
+ $this->assertFalse(in_array($this->profile, $uninstalled_modules), 'The installation profile is not in the list of uninstalled modules.');
// Enable forum module again, which should enable both the ban module and
// php module. But, this time do it with ban module declaring a dependency
// on a specific version of php module in its info file. Make sure that
- // module_enable() still works.
+ // \Drupal\Core\Extension\ModuleHandler::install() still works.
\Drupal::state()->set('module_test.dependency', 'version dependency');
drupal_static_reset('system_rebuild_module_data');
- $result = module_enable(array('forum'));
- $this->assertTrue($result, 'module_enable() returns the correct value.');
+ $result = \Drupal::moduleHandler()->install(array('forum'));
+ $this->assertTrue($result, '\Drupal\Core\Extension\ModuleHandler::install() returns the correct value.');
// Verify that the fake dependency chain was installed.
- $this->assertTrue(module_exists('ban') && module_exists('php'), 'Dependency chain was installed by module_enable().');
+ $this->assertTrue(module_exists('ban') && module_exists('php'), 'Dependency chain was installed by \Drupal\Core\Extension\ModuleHandler::install().');
// Verify that the original module was installed.
$this->assertTrue(module_exists('forum'), 'Module installation with version dependencies succeeded.');
// Finally, verify that the modules were enabled in the correct order.
- $enable_order = \Drupal::state()->get('system_test.module_enable_order') ?: array();
+ $enable_order = \Drupal::state()->get('module_test.install_order') ?: array();
$php_position = array_search('php', $enable_order);
$ban_position = array_search('ban', $enable_order);
$forum_position = array_search('forum', $enable_order);
$php_before_ban = $php_position !== FALSE && $ban_position !== FALSE && $php_position < $ban_position;
$ban_before_forum = $ban_position !== FALSE && $forum_position !== FALSE && $ban_position < $forum_position;
- $this->assertTrue($php_before_ban && $ban_before_forum, 'Modules were enabled in the correct order by module_enable().');
+ $this->assertTrue($php_before_ban && $ban_before_forum, 'Modules were enabled in the correct order by \Drupal\Core\Extension\ModuleHandler::install().');
}
/**
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleEnableTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleEnableTest.php
index d4967f8..e69de29 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleEnableTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleEnableTest.php
@@ -1,73 +0,0 @@
- 'Module enable',
- 'description' => 'Tests enabling modules.',
- 'group' => 'Module',
- );
- }
-
- /**
- * Tests enabling User module once more.
- *
- * Regression: The installer might enable a module twice due to automatic
- * dependency resolution. A bug caused the stored weight for User module to
- * be an array.
- */
- function testEnableUserTwice() {
- $this->container->get('module_handler')->enable(array('user'), FALSE);
- $this->assertIdentical(\Drupal::config('system.module')->get('enabled.user'), '0');
- }
-
- /**
- * Tests recorded schema versions of early installed modules in the installer.
- */
- function testRequiredModuleSchemaVersions() {
- $version = drupal_get_installed_schema_version('system', TRUE);
- $this->assertTrue($version > 0, 'System module version is > 0.');
- $version = drupal_get_installed_schema_version('user', TRUE);
- $this->assertTrue($version > 0, 'User module version is > 0.');
- }
-
- /**
- * Tests that an exception is thrown when a module name is too long.
- */
- function testModuleNameLength() {
- $module_name = 'invalid_module_name_over_the_maximum_allowed_character_length';
- $message = format_string('Exception thrown when enabling module %name with a name length over the allowed maximum', array('%name' => $module_name));
- try {
- $this->container->get('module_handler')->enable(array($module_name));
- $this->fail($message);
- }
- catch (ExtensionNameLengthException $e) {
- $this->pass($message);
- }
-
- // Since for the UI, the submit callback uses FALSE, test that too.
- $message = format_string('Exception thrown when enabling as if via the UI the module %name with a name length over the allowed maximum', array('%name' => $module_name));
- try {
- $this->container->get('module_handler')->enable(array($module_name), FALSE);
- $this->fail($message);
- }
- catch (ExtensionNameLengthException $e) {
- $this->pass($message);
- }
- }
-
-}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/UninstallTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/UninstallTest.php
index 78cecbf..de0e075 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/UninstallTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/UninstallTest.php
@@ -35,7 +35,6 @@ public static function getInfo() {
function testUserPermsUninstalled() {
// Uninstalls the module_test module, so hook_modules_uninstalled()
// is executed.
- module_disable(array('module_test'));
module_uninstall(array('module_test'));
// Are the perms defined by module_test removed?
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php
index 7998af1..c48e8a2 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php
@@ -12,13 +12,6 @@
*/
class VersionTest extends ModuleTestBase {
- /**
- * Modules to enable.
- *
- * @var array
- */
- public static $modules = array('module_test');
-
public static function getInfo() {
return array(
'name' => 'Module versions',
diff --git a/core/modules/system/lib/Drupal/system/Tests/ServiceProvider/ServiceProviderTest.php b/core/modules/system/lib/Drupal/system/Tests/ServiceProvider/ServiceProviderTest.php
index bffd0f0..ffe398f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/ServiceProvider/ServiceProviderTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/ServiceProvider/ServiceProviderTest.php
@@ -46,12 +46,12 @@ function testServiceProviderRegistration() {
* Tests that the DIC keeps up with module enable/disable in the same request.
*/
function testServiceProviderRegistrationDynamic() {
- // Disable the module and ensure the service provider's service is not registered.
- module_disable(array('service_provider_test'));
+ // Uninstall the module and ensure the service provider's service is not registered.
+ \Drupal::moduleHandler()->uninstall(array('service_provider_test'));
$this->assertFalse(drupal_container()->has('service_provider_test_class'), 'The service_provider_test_class service does not exist in the DIC.');
- // Enable the module and ensure the service provider's service is registered.
- module_enable(array('service_provider_test'));
+ // Install the module and ensure the service provider's service is registered.
+ \Drupal::moduleHandler()->install(array('service_provider_test'));
$this->assertTrue(drupal_container()->has('service_provider_test_class'), 'The service_provider_test_class service exists in the DIC.');
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DefaultMobileMetaTagsTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DefaultMobileMetaTagsTest.php
index e5a3b98..ba0889f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/DefaultMobileMetaTagsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/DefaultMobileMetaTagsTest.php
@@ -42,7 +42,7 @@ public function testDefaultMetaTagsExist() {
* Verifies that the default mobile meta tags can be removed.
*/
public function testRemovingDefaultMetaTags() {
- module_enable(array('system_module_test'));
+ \Drupal::moduleHandler()->install(array('system_module_test'));
$this->drupalGet('');
foreach ($this->default_metatags as $name => $metatag) {
$this->assertNoRaw($metatag, String::format('Default Mobile meta tag "@name" removed properly.', array('@name' => $name)), 'System');
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/InfoAlterTest.php b/core/modules/system/lib/Drupal/system/Tests/System/InfoAlterTest.php
index aa2e1ae..c739dd9 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/InfoAlterTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/InfoAlterTest.php
@@ -31,7 +31,7 @@ public static function getInfo() {
function testSystemInfoAlter() {
// Enable seven and the test module.
theme_enable(array('seven'));
- module_enable(array('module_test'), FALSE);
+ \Drupal::moduleHandler()->install(array('module_test'), FALSE);
$this->assertTrue(module_exists('module_test'), 'Test module is enabled.');
// Verify that the rebuilt and altered theme info is returned.
@@ -44,19 +44,5 @@ function testSystemInfoAlter() {
$this->assertTrue(isset($info['regions']['test_region']), 'Altered theme info was returned by system_list().');
$list_themes = list_themes();
$this->assertTrue(isset($list_themes['seven']->info['regions']['test_region']), 'Altered theme info was returned by list_themes().');
-
- // Disable the module and verify that rebuilt .info.yml does not contain it.
- module_disable(array('module_test'), FALSE);
- $this->assertFalse(module_exists('module_test'), 'Test module is disabled.');
-
- $info = system_get_info('theme', 'seven');
- $this->assertFalse(isset($info['regions']['test_region']), 'Altered theme info was not returned by system_get_info().');
- $seven_regions = system_region_list('seven');
- $this->assertFalse(isset($seven_regions['test_region']), 'Altered theme info was not returned by system_region_list().');
- $system_list_themes = system_list('theme');
- $info = $system_list_themes['seven']->info;
- $this->assertFalse(isset($info['regions']['test_region']), 'Altered theme info was not returned by system_list().');
- $list_themes = list_themes();
- $this->assertFalse(isset($list_themes['seven']->info['regions']['test_region']), 'Altered theme info was not returned by list_themes().');
}
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php b/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php
index ae39a10..99af2dd 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php
@@ -52,12 +52,13 @@ function setUp() {
*/
function testMainContentFallback() {
$edit = array();
- // Disable the block module.
- $edit['modules[Core][block][enable]'] = FALSE;
- $this->drupalPost('admin/modules', $edit, t('Save configuration'));
- $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
+ // Uninstall the block module.
+ $edit['uninstall[block]'] = 'block';
+ $this->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
+ $this->drupalPost(NULL, NULL, t('Uninstall'));
+ $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
$this->rebuildContainer();
- $this->assertFalse(module_exists('block'), 'Block module disabled.');
+ $this->assertFalse(module_exists('block'), 'Block module uninstall.');
// At this point, no region is filled and fallback should be triggered.
$this->drupalGet('admin/config/system/site-information');
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php
index d3476f7..b584a33 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php
@@ -254,7 +254,7 @@ function testSwitchDefaultTheme() {
* Test that themes can't be enabled when the base theme or engine is missing.
*/
function testInvalidTheme() {
- module_enable(array('theme_page_test'));
+ \Drupal::moduleHandler()->install(array('theme_page_test'));
$this->drupalGet('admin/appearance');
$this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', array('@base_theme' => 'not_real_test_basetheme')), 'Invalid base theme check succeeded.');
$this->assertText(t('This theme requires the theme engine @theme_engine to operate correctly.', array('@theme_engine' => 'not_real_engine')), 'Invalid theme engine check succeeded.');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
index a633558..5733ac3 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
@@ -219,29 +219,6 @@ function testThemeGetSetting() {
}
/**
- * Ensures the theme registry is rebuilt when modules are disabled/enabled.
- */
- function testRegistryRebuild() {
- $this->assertIdentical(theme('theme_test_foo', array('foo' => 'a')), 'a', 'The theme registry contains theme_test_foo.');
-
- module_disable(array('theme_test'), FALSE);
- // After enabling/disabling a module during a test, we need to rebuild the
- // container and ensure the extension handler is loaded, otherwise theme()
- // throws an exception.
- $this->rebuildContainer();
- $this->container->get('module_handler')->loadAll();
- $this->assertIdentical(theme('theme_test_foo', array('foo' => 'b')), FALSE, 'The theme registry does not contain theme_test_foo, because the module is disabled.');
-
- module_enable(array('theme_test'), FALSE);
- // After enabling/disabling a module during a test, we need to rebuild the
- // container and ensure the extension handler is loaded, otherwise theme()
- // throws an exception.
- $this->rebuildContainer();
- $this->container->get('module_handler')->loadAll();
- $this->assertIdentical(theme('theme_test_foo', array('foo' => 'c')), 'c', 'The theme registry contains theme_test_foo again after re-enabling the module.');
- }
-
- /**
* Tests child element rendering for 'render element' theme hooks.
*/
function testDrupalRenderChildren() {
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php
index 6aa50b2..64dc1ba 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php
@@ -47,7 +47,7 @@ public function testDisabledUpgrade() {
}
}
$to_enable = array_diff_key($available, $enabled);
- module_enable(array_keys($to_enable));
+ \Drupal::moduleHandler()->install(array_keys($to_enable));
// Check for updates.
require_once DRUPAL_ROOT . '/core/includes/update.inc';
require_once DRUPAL_ROOT . '/core/includes/install.inc';
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index df7ef6f..8657ee6 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -663,11 +663,11 @@ function theme_system_modules_uninstall($variables) {
// Display table.
$rows = array();
foreach (element_children($form['modules']) as $module) {
- if (!empty($form['modules'][$module]['#dependents'])) {
- $disabled_message = format_plural(count($form['modules'][$module]['#dependents']),
+ if (!empty($form['modules'][$module]['#required_by'])) {
+ $disabled_message = format_plural(count($form['modules'][$module]['#required_by']),
'To uninstall @module, the following module must be uninstalled first: @required_modules',
'To uninstall @module, the following modules must be uninstalled first: @required_modules',
- array('@module' => $form['modules'][$module]['#module_name'], '@required_modules' => implode(', ', $form['modules'][$module]['#dependents'])));
+ array('@module' => $form['modules'][$module]['#module_name'], '@required_modules' => implode(', ', $form['modules'][$module]['#required_by'])));
$disabled_message = '' . $disabled_message . '
';
}
else {
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index 49e87a0..2903d09 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -1929,26 +1929,12 @@ function hook_rebuild() {
}
/**
- * Perform necessary actions before modules are installed.
+ * Perform necessary actions before a module is installed.
*
- * This function allows all modules to react prior to a module being installed.
- *
- * @param $modules
- * An array of modules about to be installed.
- */
-function hook_modules_preinstall($modules) {
- mymodule_cache_clear();
-}
-
-/**
- * Perform necessary actions before modules are enabled.
- *
- * This function allows all modules to react prior to a module being enabled.
- *
- * @param $module
- * An array of modules about to be enabled.
+ * @param string $module
+ * The name of the module about to be installed.
*/
-function hook_modules_preenable($modules) {
+function hook_module_preinstall($module) {
mymodule_cache_clear();
}
@@ -1958,14 +1944,13 @@ function hook_modules_preenable($modules) {
* This function differs from hook_install() in that it gives all other modules
* a chance to perform actions when a module is installed, whereas
* hook_install() is only called on the module actually being installed. See
- * module_enable() for a detailed description of the order in which install and
- * enable hooks are invoked.
+ * \Drupal\Core\Extension\ModuleHandler::install() for a detailed description of
+ * the order in which install and enable hooks are invoked.
*
* @param $modules
* An array of the modules that were installed.
*
- * @see module_enable()
- * @see hook_modules_enabled()
+ * @see \Drupal\Core\Extension\ModuleHandler::install()
* @see hook_install()
*/
function hook_modules_installed($modules) {
@@ -1975,45 +1960,13 @@ function hook_modules_installed($modules) {
}
/**
- * Perform necessary actions after modules are enabled.
- *
- * This function differs from hook_enable() in that it gives all other modules a
- * chance to perform actions when modules are enabled, whereas hook_enable() is
- * only called on the module actually being enabled. See module_enable() for a
- * detailed description of the order in which install and enable hooks are
- * invoked.
- *
- * @param $modules
- * An array of the modules that were enabled.
+ * Perform necessary actions before a module is uninstalled.
*
- * @see hook_enable()
- * @see hook_modules_installed()
- * @see module_enable()
+ * @param string $modules
+ * The name of the module about to be uninstalled.
*/
-function hook_modules_enabled($modules) {
- if (in_array('lousy_module', $modules)) {
- drupal_set_message(t('mymodule is not compatible with lousy_module'), 'error');
- mymodule_disable_functionality();
- }
-}
-
-/**
- * Perform necessary actions after modules are disabled.
- *
- * This function differs from hook_disable() in that it gives all other modules
- * a chance to perform actions when modules are disabled, whereas hook_disable()
- * is only called on the module actually being disabled.
- *
- * @param $modules
- * An array of the modules that were disabled.
- *
- * @see hook_disable()
- * @see hook_modules_uninstalled()
- */
-function hook_modules_disabled($modules) {
- if (in_array('lousy_module', $modules)) {
- mymodule_enable_functionality();
- }
+function hook_module_preuninstall($module) {
+ mymodule_cache_clear();
}
/**
@@ -2327,9 +2280,9 @@ function hook_requirements($phase) {
* .module file is needed, it may be loaded with drupal_load().
*
* The tables declared by this hook will be automatically created when the
- * module is first enabled, and removed when the module is uninstalled. This
- * happens before hook_install() is invoked, and after hook_uninstall() is
- * invoked, respectively.
+ * module is installed, and removed when the module is uninstalled. This happens
+ * before hook_install() is invoked, and after hook_uninstall() is invoked,
+ * respectively.
*
* By declaring the tables used by your module via an implementation of
* hook_schema(), these tables will be available on all supported database
@@ -2501,11 +2454,10 @@ function hook_query_TAG_alter(Drupal\Core\Database\Query\AlterableInterface $que
*
* Implementations of this hook are by convention declared in the module's
* .install file. The implementation can rely on the .module file being loaded.
- * The hook will only be called the first time a module is enabled or after it
- * is re-enabled after being uninstalled. The module's schema version will be
- * set to the module's greatest numbered update hook. Because of this, any time
- * a hook_update_N() is added to the module, this function needs to be updated
- * to reflect the current version of the database schema.
+ * The hook will only be called when a module is installed. The module's schema
+ * version will be set to the module's greatest numbered update hook. Because of
+ * this, any time a hook_update_N() is added to the module, this function needs
+ * to be updated to reflect the current version of the database schema.
*
* See the @link http://drupal.org/node/146843 Schema API documentation @endlink
* for details on hook_schema and how database tables are defined.
@@ -2519,9 +2471,7 @@ function hook_query_TAG_alter(Drupal\Core\Database\Query\AlterableInterface $que
* be removed during uninstall should be removed with hook_uninstall().
*
* @see hook_schema()
- * @see module_enable()
- * @see hook_enable()
- * @see hook_disable()
+ * @see \Drupal\Core\Extension\ModuleHandler::install()
* @see hook_uninstall()
* @see hook_modules_installed()
*/
@@ -2765,35 +2715,6 @@ function hook_uninstall() {
}
/**
- * Perform necessary actions after module is enabled.
- *
- * The hook is called every time the module is enabled. It should be
- * implemented in the module's .install file. The implementation can
- * rely on the .module file being loaded.
- *
- * @see module_enable()
- * @see hook_install()
- * @see hook_modules_enabled()
- */
-function hook_enable() {
- mymodule_cache_rebuild();
-}
-
-/**
- * Perform necessary actions before module is disabled.
- *
- * The hook is called every time the module is disabled. It should be
- * implemented in the module's .install file. The implementation can rely
- * on the .module file being loaded.
- *
- * @see hook_uninstall()
- * @see hook_modules_disabled()
- */
-function hook_disable() {
- mymodule_cache_rebuild();
-}
-
-/**
* Return an array of tasks to be performed by an installation profile.
*
* Any tasks you define here will be run, in order, after the installer has
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 7777e0c..298b2a3 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -1529,7 +1529,7 @@ function system_update_8020() {
->condition('aid', 'system_block_ip_action')
->execute();
// Enable the new Ban module.
- module_enable(array('ban'));
+ Drupal::moduleHandler()->install(array('ban'));
}
else {
// Drop old table.
@@ -1542,7 +1542,7 @@ function system_update_8020() {
*/
function system_update_8021() {
// Enable the module without re-installing the schema.
- module_enable(array('action'));
+ Drupal::moduleHandler()->install(array('action'));
// Rename former System module actions.
$map = array(
'system_message_action' => 'action_message_action',
@@ -1843,7 +1843,7 @@ function system_update_8041() {
* Enable the new Entity module.
*/
function system_update_8042() {
- module_enable(array('entity'));
+ Drupal::moduleHandler()->install(array('entity'));
}
/**
@@ -1957,7 +1957,7 @@ function system_update_8047() {
*/
function system_update_8048() {
// Enable the module without re-installing the schema.
- module_enable(array('menu_link'));
+ Drupal::moduleHandler()->install(array('menu_link'));
// Add the langcode column if it doesn't exist.
if (!db_field_exists('menu_inks', 'langcode')) {
@@ -2226,7 +2226,6 @@ function system_update_8058() {
);
db_change_field('menu_links', 'module', 'module', $spec);
}
-
}
/**
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 94fbd21..3330e86 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -2415,7 +2415,7 @@ function system_check_directory($form_element) {
/**
* Returns an array of information about enabled modules or themes.
*
- * This function returns the contents of the .info.yml file for each enabled
+ * This function returns the contents of the .info.yml file for each installed
* module or theme.
*
* @param $type
@@ -2570,13 +2570,11 @@ function system_rebuild_module_data() {
$files = array();
ksort($modules);
// Add name, status, weight, and schema version.
- $enabled_modules = (array) Drupal::config('system.module')->get('enabled');
- $disabled_modules = (array) Drupal::config('system.module.disabled')->get();
- $all_modules = $enabled_modules + $disabled_modules;
+ $all_modules = (array) Drupal::config('system.module')->get('enabled');
foreach ($modules as $module => $record) {
$record->name = $module;
$record->weight = isset($all_modules[$module]) ? $all_modules[$module] : 0;
- $record->status = (int) isset($enabled_modules[$module]);
+ $record->status = (int) isset($all_modules[$module]);
$record->schema_version = SCHEMA_UNINSTALLED;
$files[$module] = $record->filename;
}
diff --git a/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module b/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module
index 962114c..19d4a55 100644
--- a/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module
+++ b/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module
@@ -8,11 +8,11 @@
/**
* Implements hook_watchdog().
*
- * This hook is called during module_enable() and since this hook
- * implementation is invoked, we have to expect that this module and dependent
- * modules have been properly installed already. So we expect to be able to
- * retrieve the entity information that has been registered by the required
- * dependency module.
+ * This hook is called during \Drupal\Core\Extension\ModuleHandler::install()
+ * and since this hook implementation is invoked, we have to expect that this
+ * module and dependent modules have been properly installed already. So we
+ * expect to be able to retrieve the entity information that has been registered
+ * by the required dependency module.
*
* @see EnableDisableTestCase::testEntityCache()
*/
diff --git a/core/modules/system/tests/modules/module_test/module_test.install b/core/modules/system/tests/modules/module_test/module_test.install
index 4cc09df..f3b274a 100644
--- a/core/modules/system/tests/modules/module_test/module_test.install
+++ b/core/modules/system/tests/modules/module_test/module_test.install
@@ -31,12 +31,3 @@ function module_test_install() {
$record = array('data' => 'Data inserted in hook_install()');
drupal_write_record('module_test', $record);
}
-
-/**
- * Implements hook_enable().
- */
-function module_test_enable() {
- $record = array('data' => 'Data inserted in hook_enable()');
- drupal_write_record('module_test', $record);
-}
-
diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module
index fd1d2e6..bfbad0d 100644
--- a/core/modules/system/tests/modules/module_test/module_test.module
+++ b/core/modules/system/tests/modules/module_test/module_test.module
@@ -150,21 +150,12 @@ function module_test_class_loading() {
}
/**
- * Implements hook_modules_enabled().
+ * Implements hook_modules_installed().
*/
-function module_test_modules_enabled($modules) {
+function module_test_modules_installed($modules) {
// Record the ordered list of modules that were passed in to this hook so we
// can check that the modules were enabled in the correct sequence.
- Drupal::state()->set('system_test.module_enable_order', $modules);
-}
-
-/**
- * Implements hook_modules_disabled().
- */
-function module_test_modules_disabled($modules) {
- // Record the ordered list of modules that were passed in to this hook so we
- // can check that the modules were disabled in the correct sequence.
- Drupal::state()->set('module_test.disable_order', $modules);
+ Drupal::state()->set('module_test.install_order', $modules);
}
/**
diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module
index ea10a04..8e2367a 100644
--- a/core/modules/system/tests/modules/system_test/system_test.module
+++ b/core/modules/system/tests/modules/system_test/system_test.module
@@ -98,28 +98,6 @@ function system_test_modules_installed($modules) {
}
/**
- * Implements hook_modules_enabled().
- */
-function system_test_modules_enabled($modules) {
- if (Drupal::state()->get('system_test.verbose_module_hooks')) {
- foreach ($modules as $module) {
- drupal_set_message(t('hook_modules_enabled fired for @module', array('@module' => $module)));
- }
- }
-}
-
-/**
- * Implements hook_modules_disabled().
- */
-function system_test_modules_disabled($modules) {
- if (Drupal::state()->get('system_test.verbose_module_hooks')) {
- foreach ($modules as $module) {
- drupal_set_message(t('hook_modules_disabled fired for @module', array('@module' => $module)));
- }
- }
-}
-
-/**
* Implements hook_modules_uninstalled().
*/
function system_test_modules_uninstalled($modules) {
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
index 13d4762..08477cb 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
@@ -202,10 +202,9 @@ function testUninstallReinstall() {
);
entity_create('field_instance', $this->instance_definition)->save();
- module_disable(array('taxonomy'));
require_once DRUPAL_ROOT . '/core/includes/install.inc';
module_uninstall(array('taxonomy'));
- module_enable(array('taxonomy'));
+ \Drupal::moduleHandler()->install(array('taxonomy'));
// Now create a vocabulary with the same name. All field instances
// connected to this vocabulary name should have been removed when the
diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install
index 39835d6..755fd50 100644
--- a/core/modules/taxonomy/taxonomy.install
+++ b/core/modules/taxonomy/taxonomy.install
@@ -6,26 +6,9 @@
*/
use Drupal\Component\Uuid\Uuid;
-use Drupal\Core\Entity\DatabaseStorageController;
use Drupal\field\Entity\Field;
/**
- * Implements hook_uninstall().
- */
-function taxonomy_uninstall() {
- Drupal::entityManager()->addNamespaces(new ArrayIterator(array(
- 'Drupal\taxonomy' => DRUPAL_ROOT . '/core/modules/taxonomy/lib',
- )));
- drupal_classloader_register('taxonomy', 'core/modules/taxonomy');
- // Remove taxonomy_term bundles.
- $config_names = config_get_storage_names_with_prefix('taxonomy.vocabulary.');
- foreach ($config_names as $config_name) {
- $vid = substr($config_name, strlen('taxonomy.vocabulary.'));
- entity_invoke_bundle_hook('delete', 'taxonomy_term', $vid);
- }
-}
-
-/**
* Implements hook_schema().
*/
function taxonomy_schema() {
@@ -204,9 +187,9 @@ function taxonomy_field_schema($field) {
*/
function taxonomy_update_dependencies() {
// Convert the 'tid' column of the taxonomy reference field to 'target_id'
- // after the field tables have been reorganized.
+ // after fields and instances have been moved to the config system.
$dependencies['taxonomy'][8007] = array(
- 'field' => 8006,
+ 'field' => 8003,
);
return $dependencies;
}
@@ -361,16 +344,16 @@ function taxonomy_update_8007() {
foreach (config_get_storage_names_with_prefix('field.field.') as $config_name) {
$field_config = Drupal::config($config_name);
// Only update taxonomy reference fields that use the default SQL storage.
- if ($field_config->get('type') == 'taxonomy_term_reference') {
+ if ($field_config->get('type') == 'taxonomy_term_reference' && $field_config->get('storage.type') == 'field_sql_storage') {
$field = new Field($field_config->get());
$tables = array(
- DatabaseStorageController::_fieldTableName($field),
- DatabaseStorageController::_fieldRevisionTableName($field),
+ _field_sql_storage_tablename($field),
+ _field_sql_storage_revision_tablename($field),
);
foreach ($tables as $table_name) {
- db_change_field($table_name, $field->name . '_tid', $field->name . '_target_id', array(
+ db_change_field($table_name, $field->id() . '_tid', $field->id() . '_target_id', array(
'description' => 'The ID of the target entity.',
'type' => 'int',
'unsigned' => TRUE,
@@ -378,8 +361,8 @@ function taxonomy_update_8007() {
));
// Change the index.
- db_drop_index($table_name, $field->name . '_tid');
- db_add_index($table_name, $field->name . '_target_id', array($field->name . '_target_id'));
+ db_drop_index($table_name, $field->id() . '_tid');
+ db_add_index($table_name, $field->id() . '_target_id', array($field->id() . '_target_id'));
}
// Update the indexes in field config as well.
diff --git a/core/modules/toolbar/toolbar.install b/core/modules/toolbar/toolbar.install
index 3d4f517..4b03662 100644
--- a/core/modules/toolbar/toolbar.install
+++ b/core/modules/toolbar/toolbar.install
@@ -18,7 +18,7 @@
*/
function toolbar_update_8000() {
// Enable the modules without re-installing the schema.
- module_enable(array('breakpoint'));
+ Drupal::moduleHandler()->install(array('breakpoint'));
}
/**
diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
index b11df97..4020fd3 100644
--- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
+++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
@@ -257,7 +257,7 @@ function testTrackerCronIndexing() {
* Tests that publish/unpublish works at admin/content/node.
*/
function testTrackerAdminUnpublish() {
- module_enable(array('views'));
+ \Drupal::moduleHandler()->install(array('views'));
$admin_user = $this->drupalCreateUser(array('access content overview', 'administer nodes', 'bypass node access'));
$this->drupalLogin($admin_user);
diff --git a/core/modules/tracker/tracker.install b/core/modules/tracker/tracker.install
index 841d74a..6858a5d 100644
--- a/core/modules/tracker/tracker.install
+++ b/core/modules/tracker/tracker.install
@@ -13,9 +13,9 @@ function tracker_uninstall() {
}
/**
- * Implements hook_enable().
+ * Implements hook_install().
*/
-function tracker_enable() {
+function tracker_install() {
$max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
if ($max_nid != 0) {
Drupal::state()->set('tracker.index_nid', $max_nid);
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
index af8d8c9..fd152ee 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
@@ -67,7 +67,7 @@ function testUserCancelWithoutPermission() {
* administer the site.
*/
function testUserCancelUid1() {
- module_enable(array('views'));
+ \Drupal::moduleHandler()->install(array('views'));
// Update uid 1's name and password to we know it.
$password = user_password();
$account = array(
@@ -276,7 +276,7 @@ function testUserAnonymize() {
*/
function testUserDelete() {
\Drupal::config('user.settings')->set('cancel_method', 'user_cancel_delete')->save();
- module_enable(array('comment'));
+ \Drupal::moduleHandler()->install(array('comment'));
$this->resetAll();
// Create a user.
@@ -392,7 +392,7 @@ function testUserWithoutEmailCancelByAdmin() {
* Create an administrative user and mass-delete other users.
*/
function testMassUserCancelByAdmin() {
- module_enable(array('views'));
+ \Drupal::moduleHandler()->install(array('views'));
\Drupal::config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save();
// Enable account cancellation notification.
\Drupal::config('user.settings')->set('notify.status_canceled', TRUE)->save();
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
index fa657c9..4441df9 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
@@ -122,7 +122,7 @@ function testPasswordRehashOnLogin() {
// containing the necessary container builder code and then verify that the
// users password gets rehashed during the login.
$overridden_count_log2 = 19;
- module_enable(array('user_custom_phpass_params_test'));
+ \Drupal::moduleHandler()->install(array('user_custom_phpass_params_test'));
$account->pass_raw = $password;
$this->drupalLogin($account);
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index 6d15166..d72efc9 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -614,7 +614,7 @@ function user_update_8011() {
// User pictures can only be migrated to the new user picture image field
// if Image module is installed.
if (!module_exists('image')) {
- $old_schema = module_enable(array('image'));
+ $old_schema = Drupal::moduleHandler()->install(array('image'));
if ($old_schema['image'] == SCHEMA_UNINSTALLED) {
// Install image.module with schema version 8002 as a previous version
// would have to create tables that would be removed again.
diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
index a4c8567..67e84a6 100644
--- a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
@@ -52,7 +52,7 @@ protected function enableViewsTestModule() {
\Drupal::state()->set('views_test_data_schema', $this->schemaDefinition());
\Drupal::state()->set('views_test_data_views_data', $this->viewsData());
- module_enable(array('views_test_data'));
+ \Drupal::moduleHandler()->install(array('views_test_data'));
$this->resetAll();
$this->rebuildContainer();
$this->container->get('module_handler')->reload();
diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayPath.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayPath.php
index 8f63b66..f8bc35a 100644
--- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayPath.php
+++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayPath.php
@@ -59,7 +59,7 @@ public function testDeleteWithNoPath() {
* Tests the menu and tab option form.
*/
public function testMenuOptions() {
- $this->container->get('module_handler')->enable(array('menu'));
+ $this->container->get('module_handler')->install(array('menu'));
$this->drupalGet('admin/structure/views/view/test_view');
// Add a new page display.
diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php
index 6ed0640..c9b019c 100644
--- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php
+++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php
@@ -31,7 +31,7 @@ public static function getInfo() {
* Tests contextual links in the preview form.
*/
protected function testPreviewContextual() {
- module_enable(array('contextual'));
+ \Drupal::moduleHandler()->install(array('contextual'));
$this->drupalGet('admin/structure/views/view/test_preview/edit');
$this->assertResponse(200);
$this->drupalPost(NULL, $edit = array(), t('Update preview'));