Commit 7d71cb2a authored by xjm's avatar xjm

Issue #2474363 by Aki Tendo, alexpott, Dom., MattA, dawehner, TR, hass, Wim...

Issue #2474363 by Aki Tendo, alexpott, Dom., MattA, dawehner, TR, hass, Wim Leers, cburschka, Berdir: Stuck in failed module install process
parent 2d9e1c5a
......@@ -84,7 +84,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
// 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.
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\EntityMalformedException;
use Drupal\simpletest\WebTestBase;
/**
......@@ -117,4 +118,31 @@ function testUninstallPage() {
$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');
}
}
# 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'
module_installer_config_test.type.*:
type: config_entity
label: 'Test entity type'
mapping:
id:
type: string
name:
type: label
label: 'Name'
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
<?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 {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment