From ef86599e9903ac51ca750dfc2108a610f9eead75 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20Mudr=C3=A1k?= Date: Thu, 22 Jan 2015 10:02:01 +0100 Subject: [PATCH] MDL-48493 admin: Fix PHP warning thrown if unable to detect component The method detect_plugin_component() returns false or string. The normalize_component() expects strings only. Passing false to it (typically when the plugin does not declare its component) caused the PHP warning. Credit goes to Ankit Agarwal for spotting this during testing. --- admin/tool/installaddon/index.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/admin/tool/installaddon/index.php b/admin/tool/installaddon/index.php index d7eb99bf66e..e493296b6ff 100644 --- a/admin/tool/installaddon/index.php +++ b/admin/tool/installaddon/index.php @@ -55,11 +55,15 @@ if ($form->is_cancelled()) { if (empty($data->plugintype)) { $versiondir = make_temp_directory('tool_installaddon/'.$jobid.'/version'); $detected = $installer->detect_plugin_component($sourcedir.'/'.$zipfilename, $versiondir); - list($detectedtype, $detectedname) = core_component::normalize_component($detected); - if ($detectedtype and $detectedname and $detectedtype !== 'core') { - $data->plugintype = $detectedtype; - } else { + if (empty($detected)) { $form->require_explicit_plugintype(); + } else { + list($detectedtype, $detectedname) = core_component::normalize_component($detected); + if ($detectedtype and $detectedname and $detectedtype !== 'core') { + $data->plugintype = $detectedtype; + } else { + $form->require_explicit_plugintype(); + } } } // Redirect to the validation page. -- 2.43.0