Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mudrd8mz committed Jan 22, 2015
1 parent edb13e3 commit ef86599
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions admin/tool/installaddon/index.php
Expand Up @@ -55,11 +55,15 @@
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.
Expand Down

0 comments on commit ef86599

Please sign in to comment.