mirror of
https://github.com/moodle/moodle.git
synced 2025-04-19 07:25:30 +02:00
MDL-38121 tell admins when plugin installed into wrong dir
This commit is contained in:
parent
f29e62cb6c
commit
bdbcb6d7fa
@ -29,6 +29,7 @@ $string['actions'] = 'Actions';
|
||||
$string['availability'] = 'Availability';
|
||||
$string['checkforupdates'] = 'Check for available updates';
|
||||
$string['checkforupdateslast'] = 'Last check done on {$a}';
|
||||
$string['detectedmisplacedplugin'] = 'Plugin "{$a->component}" is installed in incorrect location "{$a->current}", expected location is "{$a->expected}"';
|
||||
$string['displayname'] = 'Plugin name';
|
||||
$string['err_response_curl'] = 'Unable to fetch available updates data - unexpected cURL error.';
|
||||
$string['err_response_format_version'] = 'Unexpected version of the response format. Please try to re-check for available updates.';
|
||||
|
@ -9134,10 +9134,14 @@ function moodle_needs_upgrading() {
|
||||
continue;
|
||||
}
|
||||
$module = new stdClass();
|
||||
$plugin = new stdClass();
|
||||
if (!is_readable($fullmod.'/version.php')) {
|
||||
continue;
|
||||
}
|
||||
include($fullmod.'/version.php'); // defines $module with version etc
|
||||
if (!isset($module->version) and isset($plugin->version)) {
|
||||
$module = $plugin;
|
||||
}
|
||||
if (empty($installed[$mod])) {
|
||||
return true;
|
||||
} else if ($module->version > $installed[$mod]->version) {
|
||||
|
@ -2857,9 +2857,13 @@ class plugininfo_mod extends plugininfo_base {
|
||||
$versionfile = $this->full_path('version.php');
|
||||
|
||||
$module = new stdClass();
|
||||
$plugin = new stdClass();
|
||||
if (is_readable($versionfile)) {
|
||||
include($versionfile);
|
||||
}
|
||||
if (!isset($module->version) and isset($plugin->version)) {
|
||||
$module = $plugin;
|
||||
}
|
||||
return $module;
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,23 @@ class plugin_defective_exception extends moodle_exception {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @package core
|
||||
* @subpackage upgrade
|
||||
* @copyright 2009 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class plugin_misplaced_exception extends moodle_exception {
|
||||
function __construct($component, $expected, $current) {
|
||||
global $CFG;
|
||||
$a = new stdClass();
|
||||
$a->component = $component;
|
||||
$a->expected = $expected;
|
||||
$a->current = $current;
|
||||
parent::__construct('detectedmisplacedplugin', 'core_plugin', "$CFG->wwwroot/$CFG->admin/index.php", $a);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets maximum expected time needed for upgrade task.
|
||||
* Please always make sure that upgrade will not run longer!
|
||||
@ -381,12 +398,19 @@ function upgrade_plugins($type, $startcallback, $endcallback, $verbose) {
|
||||
}
|
||||
|
||||
$plugin = new stdClass();
|
||||
$module = new stdClass(); // Prevent some notices when plugin placed in wrong directory.
|
||||
require($fullplug.'/version.php'); // defines $plugin with version etc
|
||||
|
||||
if (!isset($plugin->version) and isset($module->version)) {
|
||||
$plugin = $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_defective_exception($component, 'Plugin installed in wrong folder.');
|
||||
$current = str_replace($CFG->dirroot, '$CFG->dirroot', $fullplug);
|
||||
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', get_component_directory($plugin->component));
|
||||
throw new plugin_misplaced_exception($component, $expected, $current);
|
||||
}
|
||||
}
|
||||
|
||||
@ -532,12 +556,19 @@ function upgrade_plugins_modules($startcallback, $endcallback, $verbose) {
|
||||
}
|
||||
|
||||
$module = new stdClass();
|
||||
$plugin = new stdClass(); // Prevent some notices when plugin placed in wrong directory.
|
||||
require($fullmod .'/version.php'); // defines $module with version etc
|
||||
|
||||
if (!isset($module->version) and isset($plugin->version)) {
|
||||
$module = $plugin;
|
||||
}
|
||||
|
||||
// if plugin tells us it's full name we may check the location
|
||||
if (isset($module->component)) {
|
||||
if ($module->component !== $component) {
|
||||
throw new plugin_defective_exception($component, 'Plugin installed in wrong folder.');
|
||||
$current = str_replace($CFG->dirroot, '$CFG->dirroot', $fullmod);
|
||||
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', get_component_directory($module->component));
|
||||
throw new plugin_misplaced_exception($component, $expected, $current);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,15 +734,21 @@ function upgrade_plugins_blocks($startcallback, $endcallback, $verbose) {
|
||||
throw new plugin_defective_exception('block/'.$blockname, 'Missing version.php file.');
|
||||
}
|
||||
$plugin = new stdClass();
|
||||
$module = new stdClass(); // Prevent some notices when module placed in wrong directory.
|
||||
$plugin->version = NULL;
|
||||
$plugin->cron = 0;
|
||||
include($fullblock.'/version.php');
|
||||
if (!isset($plugin->version) and isset($module->version)) {
|
||||
$plugin = $module;
|
||||
}
|
||||
$block = $plugin;
|
||||
|
||||
// if plugin tells us it's full name we may check the location
|
||||
if (isset($block->component)) {
|
||||
if ($block->component !== $component) {
|
||||
throw new plugin_defective_exception($component, 'Plugin installed in wrong folder.');
|
||||
$current = str_replace($CFG->dirroot, '$CFG->dirroot', $fullblock);
|
||||
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', get_component_directory($block->component));
|
||||
throw new plugin_misplaced_exception($component, $expected, $current);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user