Commit 98ea6973 authored by David Mudrák's avatar David Mudrák
Browse files

MDL-48494 admin: Require plugins declare their component in version.php

parent f5f5a60a
......@@ -299,6 +299,12 @@ class core_plugin_manager {
$skipcache = true;
}
// Check if the component is properly declared.
if (empty($plugin->component) or ($plugin->component !== $type.'_'.$plug)) {
debugging('Plugin '.$type.'_'.$plug.' does not declare valid $plugin->component in its version.php.');
$skipcache = true;
}
$this->presentplugins[$type][$plug] = $plugin;
}
}
......
......@@ -3,6 +3,9 @@ information provided here is intended especially for developers.
=== 3.0 ===
* All plugins are required to declare their frankenstyle component name via
the $plugin->component property in their version.php file. See
https://docs.moodle.org/dev/version.php for details (MDL-48494).
* PHPUnit is upgraded to 4.7. Some tests using deprecated assertions etc may need changes to work correctly.
* get_referer() has been deprecated, please use the get_local_referer function instead.
* \core\progress\null is renamed to \core\progress\none for improved PHP7 compatibility as null is a reserved word (see MDL-50453).
......
......@@ -450,15 +450,16 @@ function upgrade_plugins($type, $startcallback, $endcallback, $verbose) {
require($fullplug.'/version.php'); // defines $plugin with version etc
unset($module);
// if plugin tells us it's full name we may check the location
if (isset($plugin->component)) {
if ($plugin->component !== $component) {
throw new plugin_misplaced_exception($plugin->component, null, $fullplug);
}
if (empty($plugin->version)) {
throw new plugin_defective_exception($component, 'Missing $plugin->version number in version.php.');
}
if (empty($plugin->version)) {
throw new plugin_defective_exception($component, 'Missing version value in version.php');
if (empty($plugin->component)) {
throw new plugin_defective_exception($component, 'Missing $plugin->component declaration in version.php.');
}
if ($plugin->component !== $component) {
throw new plugin_misplaced_exception($plugin->component, null, $fullplug);
}
$plugin->name = $plug;
......@@ -617,16 +618,16 @@ function upgrade_plugins_modules($startcallback, $endcallback, $verbose) {
unset($module->dependencies);
unset($module->release);
// if plugin tells us it's full name we may check the location
if (isset($plugin->component)) {
if ($plugin->component !== $component) {
throw new plugin_misplaced_exception($plugin->component, null, $fullmod);
}
if (empty($plugin->version)) {
throw new plugin_defective_exception($component, 'Missing $plugin->version number in version.php.');
}
if (empty($plugin->version)) {
// Version must be always set now!
throw new plugin_defective_exception($component, 'Missing version value in version.php');
if (empty($plugin->component)) {
throw new plugin_defective_exception($component, 'Missing $plugin->component declaration in version.php.');
}
if ($plugin->component !== $component) {
throw new plugin_misplaced_exception($plugin->component, null, $fullmod);
}
if (!empty($plugin->requires)) {
......@@ -798,15 +799,16 @@ function upgrade_plugins_blocks($startcallback, $endcallback, $verbose) {
unset($block->dependencies);
unset($block->release);
// if plugin tells us it's full name we may check the location
if (isset($plugin->component)) {
if ($plugin->component !== $component) {
throw new plugin_misplaced_exception($plugin->component, null, $fullblock);
}
if (empty($plugin->version)) {
throw new plugin_defective_exception($component, 'Missing block version number in version.php.');
}
if (empty($plugin->version)) {
throw new plugin_defective_exception($component, 'Missing block version.');
if (empty($plugin->component)) {
throw new plugin_defective_exception($component, 'Missing $plugin->component declaration in version.php.');
}
if ($plugin->component !== $component) {
throw new plugin_misplaced_exception($plugin->component, null, $fullblock);
}
if (!empty($plugin->requires)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment