Unverified Commit e59e83e3 authored by larowlan's avatar larowlan

Issue #2558645 by almaudoh, Vidushi Mehta, alexpott: Malformed module.info.yml...

Issue #2558645 by almaudoh, Vidushi Mehta, alexpott: Malformed module.info.yml prevents install with a confusing error

(cherry picked from commit 2be3c894)
parent 349314ca
......@@ -7,6 +7,7 @@
use Drupal\Core\Config\UnmetDependenciesException;
use Drupal\Core\Access\AccessManagerInterface;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\InfoParserException;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\Core\Form\FormBase;
......@@ -143,8 +144,14 @@ public function buildForm(array $form, FormStateInterface $form_state) {
// Sort all modules by their names.
$modules = system_rebuild_module_data();
uasort($modules, 'system_sort_modules_by_info_name');
try {
$modules = system_rebuild_module_data();
uasort($modules, 'system_sort_modules_by_info_name');
catch (InfoParserException $e) {
$this->messenger()->addError($this->t('Modules could not be listed due to an error: %error', ['%error' => $e->getMessage()]));
$modules = [];
// Iterate over each of the modules.
$form['modules']['#tree'] = TRUE;
......@@ -51,4 +51,29 @@ public function testModuleListForm() {
public function testModulesListFormWithInvalidInfoFile() {
$broken_info_yml = <<<BROKEN
name: Module With Broken Info file
type: module
$path = \Drupal::service('site.path') . "/modules/broken";
mkdir($path, 0777, TRUE);
file_put_contents("$path/broken.info.yml", $broken_info_yml);
['administer modules', 'administer permissions']
// Confirm that the error message is shown.
->pageTextContains('Modules could not be listed due to an error: Missing required keys (core) in ' . $path . '/broken.info.yml');
// Check that the module filter text box is available.
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