From b1d57de49621d6ebe5d678e962ed908b3281c8b7 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Mon, 24 Jul 2023 09:01:33 +0100
Subject: [PATCH] Issue #2730807 by Lendude, versantus.nik, cilefen, xjm,
 SidneyGijzen, smustgrave, almaudoh, alexpott, danflanagan8, jordan.jamous:
 WSOD on admin/modules if description is set but is NULL in module.info.yml

---
 .../Drupal/Core/Extension/ExtensionList.php   |  9 ++++--
 .../Form/ModulesListFormWebTest.php           | 28 +++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/core/lib/Drupal/Core/Extension/ExtensionList.php b/core/lib/Drupal/Core/Extension/ExtensionList.php
index f12c9a61f830..38f0f9f82466 100644
--- a/core/lib/Drupal/Core/Extension/ExtensionList.php
+++ b/core/lib/Drupal/Core/Extension/ExtensionList.php
@@ -559,8 +559,13 @@ protected function createExtensionInfo(Extension $extension) {
     // contributed extensions to use for ordering extension lists.
     $info['mtime'] = $extension->getFileInfo()->getMTime();
 
-    // Merge extension type-specific defaults.
-    $info += $this->defaults;
+    // Merge extension type-specific defaults, making sure to replace NULL
+    // values.
+    foreach ($this->defaults as $key => $default_value) {
+      if (!isset($info[$key])) {
+        $info[$key] = $default_value;
+      }
+    }
 
     return $info;
   }
diff --git a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
index ab8b18e4d0ee..ac78f4b7a8ff 100644
--- a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
+++ b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
@@ -121,6 +121,34 @@ public function testModulesListFormWithInvalidInfoFile() {
     $this->assertSession()->pageTextNotContains('Modules could not be listed due to an error');
   }
 
+  /**
+   * Tests the module form with a module with an empty description in info.yml.
+   */
+  public function testModulesListFormWithEmptyDescriptionInfoFile() {
+    $path = \Drupal::getContainer()
+      ->getParameter('site.path') . "/modules/missing_description";
+    mkdir($path, 0777, TRUE);
+    $file_path = "$path/missing_description.info.yml";
+
+    $yml = <<<BROKEN
+name: Module with empty description
+type: module
+core_version_requirement: '*'
+description:
+BROKEN;
+
+    file_put_contents($file_path, $yml);
+
+    $this->drupalGet('admin/modules');
+    $this->assertSession()->statusCodeEquals(200);
+
+    $this->assertSession()
+      ->pageTextContains("Module with empty description");
+
+    // Check that the module filter text box is available.
+    $this->assertSession()->elementExists('xpath', '//input[@name="text"]');
+  }
+
   /**
    * Confirm that module 'Required By' descriptions include dependent themes.
    */
-- 
GitLab