From 0d7c4171756d05b4f3519b280e2beda5bd157f86 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20Mudr=C3=A1k?= Date: Wed, 27 Jul 2016 22:49:49 +0200 Subject: [PATCH 1/1] MDL-55166 admin: Fix display of misleading debug warning on manage block Blocks can declare has_config() as true without actually using the default node in the admin tree. Typical use case is when the block injects its settings to other parts of the admin tree and it assigns null to its $setting node in its settings.php file. As Janek L.B. correctly spotted, this led to false debugging message on admin/blocks.php as the code interpreted it as missing settings.php file. The patch adds explicit file existence test for this rare case. --- admin/blocks.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/admin/blocks.php b/admin/blocks.php index 77febe60ed7..dcf00f6001e 100644 --- a/admin/blocks.php +++ b/admin/blocks.php @@ -154,7 +154,10 @@ $settings = '' . get_string('settings') . ''; } else if ($blocksettings instanceof admin_settingpage) { $settings = ''.$strsettings.''; - } else { + } else if (!file_exists($CFG->dirroot.'/blocks/'.$block->name.'/settings.php')) { + // If the block's settings node was not found, we check that the block really provides the settings.php file. + // Note that blocks can inject their settings to other nodes in the admin tree without using the default locations. + // This can be done by assigning null to $setting in settings.php and it is a valid case. debugging('Warning: block_'.$block->name.' returns true in has_config() but does not provide a settings.php file', DEBUG_DEVELOPER); } -- 2.43.0