summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2015-07-04 12:50:08 (GMT)
committerxjm2015-07-04 12:50:08 (GMT)
commit7d71cb2a260ab00b4b7ec84744ae8e6889857516 (patch)
tree4dcbf8dced7447164c336306a816674997ba985f
parent2d9e1c5a2d9e41700784989ac5721157bb783337 (diff)
Issue #2474363 by Aki Tendo, alexpott, Dom., MattA, dawehner, TR, hass, Wim Leers, cburschka, Berdir: Stuck in failed module install process
-rw-r--r--core/modules/system/src/Form/ModulesUninstallForm.php2
-rw-r--r--core/modules/system/src/Tests/Module/UninstallTest.php28
-rw-r--r--core/modules/system/tests/modules/module_installer_config_test/config/install/module_installer_config_test.type.missing_id.yml3
-rw-r--r--core/modules/system/tests/modules/module_installer_config_test/config/schema/module_installer_config_test.schema.yml10
-rw-r--r--core/modules/system/tests/modules/module_installer_config_test/module_installer_config_test.info.yml7
-rw-r--r--core/modules/system/tests/modules/module_installer_config_test/src/Entity/TestConfigType.php30
6 files changed, 79 insertions, 1 deletions
diff --git a/core/modules/system/src/Form/ModulesUninstallForm.php b/core/modules/system/src/Form/ModulesUninstallForm.php
index f72fa43..c74439e 100644
--- a/core/modules/system/src/Form/ModulesUninstallForm.php
+++ b/core/modules/system/src/Form/ModulesUninstallForm.php
@@ -84,7 +84,7 @@ class ModulesUninstallForm extends FormBase {
// Get a list of all available modules.
$modules = system_rebuild_module_data();
$uninstallable = array_filter($modules, function ($module) use ($modules) {
- return empty($modules[$module->getName()]->info['required']) && drupal_get_installed_schema_version($module->getName()) > SCHEMA_UNINSTALLED;
+ return empty($modules[$module->getName()]->info['required']) && $module->status;
});
// Include system.admin.inc so we can use the sort callbacks.
diff --git a/core/modules/system/src/Tests/Module/UninstallTest.php b/core/modules/system/src/Tests/Module/UninstallTest.php
index f060986..8730522 100644
--- a/core/modules/system/src/Tests/Module/UninstallTest.php
+++ b/core/modules/system/src/Tests/Module/UninstallTest.php
@@ -9,6 +9,7 @@ namespace Drupal\system\Tests\Module;
use Drupal\Core\Cache\Cache;
use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Core\Entity\EntityMalformedException;
use Drupal\simpletest\WebTestBase;
/**
@@ -117,4 +118,31 @@ class UninstallTest extends WebTestBase {
$this->assertUrl('admin/modules/uninstall');
$this->assertTitle(t('Uninstall') . ' | Drupal');
}
+
+ /**
+ * Tests that a module which fails to install can still be uninstalled.
+ */
+ public function testFailedInstallStatus() {
+ $account = $this->drupalCreateUser(array('administer modules'));
+ $this->drupalLogin($account);
+
+ $message = 'Exception thrown when installing module_installer_config_test with an invalid configuration file.';
+ try {
+ $this->container->get('module_installer')->install(array('module_installer_config_test'));
+ $this->fail($message);
+ } catch (EntityMalformedException $e) {
+ $this->pass($message);
+ }
+
+ // Even though the module failed to install properly, its configuration
+ // status is "enabled" and should still be available to uninstall.
+ $this->drupalGet('admin/modules/uninstall');
+ $this->assertText('Module installer config test');
+ $edit['uninstall[module_installer_config_test]'] = TRUE;
+ $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
+ $this->drupalPostForm(NULL, NULL, t('Uninstall'));
+ $this->assertText(t('The selected modules have been uninstalled.'));
+ $this->assertNoText('Module installer config test');
+ }
+
}
diff --git a/core/modules/system/tests/modules/module_installer_config_test/config/install/module_installer_config_test.type.missing_id.yml b/core/modules/system/tests/modules/module_installer_config_test/config/install/module_installer_config_test.type.missing_id.yml
new file mode 100644
index 0000000..4628b97
--- /dev/null
+++ b/core/modules/system/tests/modules/module_installer_config_test/config/install/module_installer_config_test.type.missing_id.yml
@@ -0,0 +1,3 @@
+# This entity is intentionally missing an 'id' key. During installation, an
+# EntityMalformedException should be thrown about the missing key.
+name: 'This entity does not have an ID'
diff --git a/core/modules/system/tests/modules/module_installer_config_test/config/schema/module_installer_config_test.schema.yml b/core/modules/system/tests/modules/module_installer_config_test/config/schema/module_installer_config_test.schema.yml
new file mode 100644
index 0000000..cb39936
--- /dev/null
+++ b/core/modules/system/tests/modules/module_installer_config_test/config/schema/module_installer_config_test.schema.yml
@@ -0,0 +1,10 @@
+module_installer_config_test.type.*:
+ type: config_entity
+ label: 'Test entity type'
+ mapping:
+ id:
+ type: string
+ name:
+ type: label
+ label: 'Name'
+
diff --git a/core/modules/system/tests/modules/module_installer_config_test/module_installer_config_test.info.yml b/core/modules/system/tests/modules/module_installer_config_test/module_installer_config_test.info.yml
new file mode 100644
index 0000000..78f3d88
--- /dev/null
+++ b/core/modules/system/tests/modules/module_installer_config_test/module_installer_config_test.info.yml
@@ -0,0 +1,7 @@
+name: 'Module installer config test'
+description: 'Support module for tests that require a failed module install.'
+type: module
+package: Testing
+core: 8.x
+version: VERSION
+
diff --git a/core/modules/system/tests/modules/module_installer_config_test/src/Entity/TestConfigType.php b/core/modules/system/tests/modules/module_installer_config_test/src/Entity/TestConfigType.php
new file mode 100644
index 0000000..cddb92e
--- /dev/null
+++ b/core/modules/system/tests/modules/module_installer_config_test/src/Entity/TestConfigType.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\module_installer_config_test\Entity\TestConfigType.
+ */
+
+namespace Drupal\module_installer_config_test\Entity;
+
+use Drupal\Core\Config\Entity\ConfigEntityBase;
+
+/**
+ * Defines a configuration-based entity type used for testing.
+ *
+ * @ConfigEntityType(
+ * id = "test_config_type",
+ * label = @Translation("Test entity type"),
+ * handlers = {
+ * "list_builder" = "Drupal\Core\Entity\EntityListBuilder"
+ * },
+ * admin_permission = "administer modules",
+ * config_prefix = "type",
+ * entity_keys = {
+ * "id" = "id",
+ * "label" = "name"
+ * }
+ * )
+ */
+class TestConfigType extends ConfigEntityBase {
+}