Issue by jonathan1055, smustgrave: htmlspecialchars(): Passing null to parameter ($string) of type string is deprecated

merge-requests/1662/merge
catch 2023-01-05 16:26:50 +00:00
parent 0cbb0a30ec
commit d98f56134e
2 changed files with 22 additions and 2 deletions
core
lib/Drupal/Core/Extension
modules/system/tests/src/Functional/Module

View File

@ -44,7 +44,7 @@ trait ModuleDependencyMessageTrait {
$constraint_string = $dependency_object->getConstraintString();
return $this->t('@module_name (<span class="admin-missing">incompatible with</span> version @version)', [
'@module_name' => "$module_name ($constraint_string)",
'@version' => $modules[$dependency]->info['version'],
'@version' => $modules[$dependency]->info['version'] ?? '* ? *',
]);
}
}

View File

@ -112,14 +112,34 @@ class DependencyTest extends ModuleTestBase {
mkdir($path, 0777, TRUE);
file_put_contents("$path/system_no_module_version_dependency_test.info.yml", Yaml::encode($info));
// Include a version in the dependency definition, to test the 'incompatible
// with version' message when no version is given in the required module.
$info = [
'type' => 'module',
'core_version_requirement' => '*',
'name' => 'System no module version test',
'dependencies' => ['system_no_module_version_dependency_test(>1.x)'],
];
$path = $this->siteDirectory . '/modules/system_no_module_version_test';
mkdir($path, 0777, TRUE);
file_put_contents("$path/system_no_module_version_test.info.yml", Yaml::encode($info));
// Ensure that the module list page is displayed without errors.
$this->drupalGet('admin/modules');
$this->assertSession()->pageTextContains('System no module version test');
$this->assertSession()->pageTextContains('System no module version dependency test (>1.x) (incompatible with version');
$this->assertSession()->fieldEnabled('modules[system_no_module_version_dependency_test][enable]');
$this->assertSession()->fieldDisabled('modules[system_no_module_version_test][enable]');
// Remove the version requirement from the the dependency definition
$info = [
'type' => 'module',
'core_version_requirement' => '*',
'name' => 'System no module version test',
'dependencies' => ['system_no_module_version_dependency_test'],
];
$path = $this->siteDirectory . '/modules/system_no_module_version_test';
mkdir($path, 0777, TRUE);
file_put_contents("$path/system_no_module_version_test.info.yml", Yaml::encode($info));
$this->drupalGet('admin/modules');