summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLee Rowlands2019-01-12 08:37:53 (GMT)
committerLee Rowlands2019-01-12 08:37:53 (GMT)
commit12dbf59a291528a18ade9fdbd3de184ed22f8c62 (patch)
tree1c92af1f38e40cb245d422bb6953847b6f4bd349 /core
parente91e2874a6afbd9b794f54d1cad0787ff5f86ba9 (diff)
Issue #3000677 by catch, Shane Birley, featherbelly, alexpott, larowlan: Fatal error after upgrade to 8.6x [due to regression in extension system]
Diffstat (limited to 'core')
-rw-r--r--core/lib/Drupal/Core/Extension/ModuleHandler.php7
-rw-r--r--core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerTest.php24
2 files changed, 30 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php
index 8d43a85..d623988 100644
--- a/core/lib/Drupal/Core/Extension/ModuleHandler.php
+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -777,7 +777,12 @@ class ModuleHandler implements ModuleHandlerInterface {
* {@inheritdoc}
*/
public function getName($module) {
- return \Drupal::service('extension.list.module')->getName($module);
+ try {
+ return \Drupal::service('extension.list.module')->getName($module);
+ }
+ catch (UnknownExtensionException $e) {
+ return $module;
+ }
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerTest.php
new file mode 100644
index 0000000..a826706
--- /dev/null
+++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerTest.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Drupal\KernelTests\Core\Extension;
+
+use Drupal\KernelTests\KernelTestBase;
+
+/**
+ * @coversDefaultClass \Drupal\Core\Extension\ModuleHandler
+ *
+ * @group Extension
+ */
+class ModuleHandlerTest extends KernelTestBase {
+
+ /**
+ * Tests requesting the name of an invalid module.
+ *
+ * @covers ::getName
+ */
+ public function testInvalidGetName() {
+ $module_handler = $this->container->get('module_handler');
+ $this->assertSame('module_nonsense', $module_handler->getName('module_nonsense'));
+ }
+
+}