Issue #3182785 by mcdruid, mar4ehk0, elsteff1385, John Franklin: PHP 7.4 notice in /modules/system/system.admin.inc when a module has an invalid configure path

merge-requests/2343/head
mcdruid 2022-05-27 10:12:10 +01:00
parent 6c6045d64d
commit c91d728188
4 changed files with 33 additions and 1 deletions

View File

@ -122,6 +122,19 @@ class ModuleUnitTest extends DrupalWebTestCase {
$this->assertText('System null version test', 'Module admin UI listed dependency with null version successfully.');
}
/**
* Test system_modules() with a module with a broken configure path.
*/
function testSystemModulesBrokenConfigure() {
module_enable(array('system_admin_test'));
$this->resetAll();
$admin = $this->drupalCreateUser(array('administer modules'));
$this->drupalLogin($admin);
$this->drupalGet('admin/modules');
$module_log = db_query_range('SELECT message FROM {watchdog} WHERE type = :type ORDER BY wid DESC', 0, 1, array(':type' => 'system'))->fetchField();
$this->assertEqual('Module %module specifies an invalid path for configuration: %configure', $module_log, 'An error was logged for the module\'s broken configure path.');
}
/**
* Test that module_invoke() can load a hook defined in hook_hook_info().
*/

View File

@ -0,0 +1,7 @@
name = System Admin Test
description = 'Support module for testing system.admin.inc.'
package = Only For Testing
version = VERSION
core = 7.x
hidden = FALSE
configure = config/broken

View File

@ -0,0 +1,6 @@
<?php
/**
* @file
* Helper module for module for testing system.admin.inc.
*/

View File

@ -886,7 +886,13 @@ function system_modules($form, $form_state = array()) {
// one.
if ($module->status && isset($module->info['configure'])) {
$configure_link = menu_get_item($module->info['configure']);
if ($configure_link['access']) {
if ($configure_link === FALSE) {
watchdog('system', 'Module %module specifies an invalid path for configuration: %configure', array(
'%module' => $module->info['name'],
'%configure' => $module->info['configure'],
));
}
else if ($configure_link['access']) {
$extra['links']['configure'] = array(
'#type' => 'link',
'#title' => t('Configure'),