Merge branch 'MDL-48494-master-component' of git://github.com/mudrd8mz/moodle
This commit is contained in:
@@ -322,22 +322,25 @@ class tool_installaddon_validator {
|
||||
$this->add_message(self::INFO, 'requiresmoodle', $this->versionphp['requires']);
|
||||
}
|
||||
|
||||
if (isset($info['plugin->component'])) {
|
||||
$this->versionphp['component'] = $info['plugin->component'];
|
||||
list($reqtype, $reqname) = core_component::normalize_component($this->versionphp['component']);
|
||||
if ($reqtype !== $this->assertions['plugintype']) {
|
||||
$this->add_message(self::ERROR, 'componentmismatchtype', array(
|
||||
'expected' => $this->assertions['plugintype'],
|
||||
'found' => $reqtype));
|
||||
return false;
|
||||
}
|
||||
if ($reqname !== $this->rootdir) {
|
||||
$this->add_message(self::ERROR, 'componentmismatchname', $reqname);
|
||||
return false;
|
||||
}
|
||||
$this->add_message(self::INFO, 'componentmatch', $this->versionphp['component']);
|
||||
if (!isset($info['plugin->component'])) {
|
||||
$this->add_message(self::ERROR, 'missingcomponent');
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->versionphp['component'] = $info['plugin->component'];
|
||||
list($reqtype, $reqname) = core_component::normalize_component($this->versionphp['component']);
|
||||
if ($reqtype !== $this->assertions['plugintype']) {
|
||||
$this->add_message(self::ERROR, 'componentmismatchtype', array(
|
||||
'expected' => $this->assertions['plugintype'],
|
||||
'found' => $reqtype));
|
||||
return false;
|
||||
}
|
||||
if ($reqname !== $this->rootdir) {
|
||||
$this->add_message(self::ERROR, 'componentmismatchname', $reqname);
|
||||
return false;
|
||||
}
|
||||
$this->add_message(self::INFO, 'componentmatch', $this->versionphp['component']);
|
||||
|
||||
if (isset($info['plugin->maturity'])) {
|
||||
$this->versionphp['maturity'] = $info['plugin->maturity'];
|
||||
if ($this->versionphp['maturity'] === 'MATURITY_STABLE') {
|
||||
|
||||
@@ -71,6 +71,9 @@ $string['validationmsg_filestatus_info'] = 'Attempting to extract file {$a->file
|
||||
$string['validationmsg_foundlangfile'] = 'Found language file';
|
||||
$string['validationmsg_maturity'] = 'Declared maturity level';
|
||||
$string['validationmsg_maturity_help'] = 'The plugin can declare its maturity level. If the maintainer considers the plugin stable, the declared maturity level will read MATURITY_STABLE. All other maturity levels (such as alpha or beta) should be considered unstable and a warning is raised.';
|
||||
$string['validationmsg_missingcomponent'] = 'Plugin does not declare its component name';
|
||||
$string['validationmsg_missingcomponent_help'] = 'All plugins must provide their full component name via the `$plugin->component` declaration in the version.php file.';
|
||||
$string['validationmsg_missingcomponent_link'] = 'Development:version.php';
|
||||
$string['validationmsg_missingexpectedlangenfile'] = 'English language file name mismatch';
|
||||
$string['validationmsg_missingexpectedlangenfile_info'] = 'The given plugin type is missing the expected English language file {$a}.';
|
||||
$string['validationmsg_missinglangenfile'] = 'No English language file found';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$string['pluginname'] = 'This is a plugin with $plugin->component missing in its version.php';
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
$plugin->version = 2015080600;
|
||||
$plugin->release = 'B.A.Z. Auth fake plugin';
|
||||
//$plugin->component is missing here so the validation must fail.
|
||||
@@ -1,3 +1,4 @@
|
||||
<?php
|
||||
|
||||
$plugin->version = 2014122455;
|
||||
$plugin->component = 'mod_bah';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$string['pluginname'] = 'This would be valid filename for module, not a block';
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
$plugin->version = 2014122455;
|
||||
$plugin->component = 'block_bah';
|
||||
@@ -145,6 +145,17 @@ class tool_installaddon_validator_testcase extends basic_testcase {
|
||||
$this->assertFalse($validator->execute());
|
||||
$this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'versionphpsyntax', '$module'));
|
||||
|
||||
$validator = testable_tool_installaddon_validator::instance($fixtures.'/nocomponent', array(
|
||||
'baz/' => true,
|
||||
'baz/version.php' => true,
|
||||
'baz/lang/' => true,
|
||||
'baz/lang/en/' => true,
|
||||
'baz/lang/en/auth_baz.php' => true));
|
||||
$validator->assert_plugin_type('auth');
|
||||
$validator->assert_moodle_version(0);
|
||||
$this->assertFalse($validator->execute());
|
||||
$this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'missingcomponent'));
|
||||
|
||||
$validator = testable_tool_installaddon_validator::instance($fixtures.'/plugindir', array(
|
||||
'foobar/' => true,
|
||||
'foobar/version.php' => true,
|
||||
@@ -216,7 +227,7 @@ class tool_installaddon_validator_testcase extends basic_testcase {
|
||||
$this->assertTrue($this->has_message($validator->get_messages(), $validator::WARNING, 'multiplelangenfiles'));
|
||||
$this->assertTrue(is_null($validator->get_language_file_name()));
|
||||
|
||||
$validator = testable_tool_installaddon_validator::instance($fixtures.'/nolang', array(
|
||||
$validator = testable_tool_installaddon_validator::instance($fixtures.'/wronglang', array(
|
||||
'bah/' => true,
|
||||
'bah/version.php' => true,
|
||||
'bah/lang/' => true,
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = 'tool_installaddon';
|
||||
$plugin->version = 2015051100;
|
||||
$plugin->version = 2015080601;
|
||||
$plugin->requires = 2015050500;
|
||||
$plugin->maturity = MATURITY_STABLE;
|
||||
|
||||
@@ -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.
|
||||
* Users of the text editor API to manually create a text editor should call set_text before calling use_editor.
|
||||
* get_referer() has been deprecated, please use the get_local_referer function instead.
|
||||
|
||||
+24
-22
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user