mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-66917 admin: validate uploaded plugin version.
Prevent overwriting current plugins with older versions of themselves.
This commit is contained in:
parent
788dfb9c7d
commit
59f941f6db
2 changed files with 8 additions and 0 deletions
|
@ -232,6 +232,7 @@ $string['validationmsg_onedir'] = 'Invalid structure of the ZIP package.';
|
||||||
$string['validationmsg_onedir_help'] = 'The ZIP package must contain just one root directory that holds the plugin code. The name of that root directory must match the name of the plugin.';
|
$string['validationmsg_onedir_help'] = 'The ZIP package must contain just one root directory that holds the plugin code. The name of that root directory must match the name of the plugin.';
|
||||||
$string['validationmsg_pathwritable'] = 'Write access check';
|
$string['validationmsg_pathwritable'] = 'Write access check';
|
||||||
$string['validationmsg_pluginversion'] = 'Plugin version';
|
$string['validationmsg_pluginversion'] = 'Plugin version';
|
||||||
|
$string['validationmsg_pluginversiontoolow'] = 'A higher version of this plugin is already installed';
|
||||||
$string['validationmsg_release'] = 'Plugin release';
|
$string['validationmsg_release'] = 'Plugin release';
|
||||||
$string['validationmsg_requiresmoodle'] = 'Required Moodle version';
|
$string['validationmsg_requiresmoodle'] = 'Required Moodle version';
|
||||||
$string['validationmsg_rootdir'] = 'Name of the plugin to be installed';
|
$string['validationmsg_rootdir'] = 'Name of the plugin to be installed';
|
||||||
|
|
|
@ -394,6 +394,13 @@ class validator {
|
||||||
}
|
}
|
||||||
$this->add_message(self::INFO, 'componentmatch', $this->versionphp['component']);
|
$this->add_message(self::INFO, 'componentmatch', $this->versionphp['component']);
|
||||||
|
|
||||||
|
// Ensure the version we are uploading is higher than the version currently installed.
|
||||||
|
$plugininfo = $this->get_plugin_manager()->get_plugin_info($this->versionphp['component']);
|
||||||
|
if (!is_null($plugininfo) && $this->versionphp['version'] < $plugininfo->versiondb) {
|
||||||
|
$this->add_message(self::ERROR, 'pluginversiontoolow', $plugininfo->versiondb);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($info['plugin->maturity'])) {
|
if (isset($info['plugin->maturity'])) {
|
||||||
$this->versionphp['maturity'] = $info['plugin->maturity'];
|
$this->versionphp['maturity'] = $info['plugin->maturity'];
|
||||||
if ($this->versionphp['maturity'] === 'MATURITY_STABLE') {
|
if ($this->versionphp['maturity'] === 'MATURITY_STABLE') {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue