Merge branch 'MDL-81870-404' of https://github.com/paulholden/moodle into MOODLE_404_STABLE

This commit is contained in:
Andrew Nicols 2024-05-28 14:00:15 +08:00
commit 5182b60391
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
2 changed files with 12 additions and 69 deletions

View File

@ -503,6 +503,7 @@ $string['pagenotexist'] = '<p>An unusual error occurred trying to view a page th
$string['passwordexceeded'] = 'The password can\'t be more than {$a} characters.';
$string['pathdoesnotstartslash'] = 'No valid arguments supplied, path does not start with slash!';
$string['pleasereport'] = 'If you have time, please let us know what you were trying to do when the error occurred:';
$string['pluginnotexist'] = '{$a} plugin doesn\'t exist';
$string['pluginrequirementsnotmet'] = 'Plugin "{$a->pluginname}" ({$a->pluginversion}) could not be installed. It requires a newer version of Moodle (currently you are using {$a->currentmoodle}, you need {$a->requiremoodle}).';
$string['pluginunsupported'] = 'Plugin "{$a->pluginname}" {$a->pluginversion} does not support this version of Moodle {$a->moodleversion}. Seek plugin information to find supported versions.';
$string['prefixcannotbeempty'] = '<p>Error: database table prefix cannot be empty ({$a})</p>

View File

@ -373,43 +373,12 @@ function upgrade_main_savepoint($result, $version, $allowabort=true) {
*
* @category upgrade
* @param bool $result false if upgrade step failed, true if completed
* @param string or float $version main version
* @param string|float $version main version
* @param string $modname name of module
* @param bool $allowabort allow user to abort script execution here
* @return void
*/
function upgrade_mod_savepoint($result, $version, $modname, $allowabort=true) {
global $DB;
$component = 'mod_'.$modname;
if (!$result) {
throw new upgrade_exception($component, $version);
}
$dbversion = $DB->get_field('config_plugins', 'value', array('plugin'=>$component, 'name'=>'version'));
if (!$module = $DB->get_record('modules', array('name'=>$modname))) {
throw new \moodle_exception('modulenotexist', 'debug', '', $modname);
}
if ($dbversion >= $version) {
// something really wrong is going on in upgrade script
throw new downgrade_exception($component, $dbversion, $version);
}
set_config('version', $version, $component);
upgrade_log(UPGRADE_LOG_NORMAL, $component, 'Upgrade savepoint reached');
// reset upgrade timeout to default
upgrade_set_timeout();
core_upgrade_time::record_savepoint($version);
// this is a safe place to stop upgrades if user aborts page loading
if ($allowabort and connection_aborted()) {
die;
}
upgrade_plugin_savepoint($result, $version, 'mod', $modname, $allowabort);
}
/**
@ -419,57 +388,25 @@ function upgrade_mod_savepoint($result, $version, $modname, $allowabort=true) {
*
* @category upgrade
* @param bool $result false if upgrade step failed, true if completed
* @param string or float $version main version
* @param string|float $version main version
* @param string $blockname name of block
* @param bool $allowabort allow user to abort script execution here
* @return void
*/
function upgrade_block_savepoint($result, $version, $blockname, $allowabort=true) {
global $DB;
$component = 'block_'.$blockname;
if (!$result) {
throw new upgrade_exception($component, $version);
}
$dbversion = $DB->get_field('config_plugins', 'value', array('plugin'=>$component, 'name'=>'version'));
if (!$block = $DB->get_record('block', array('name'=>$blockname))) {
throw new \moodle_exception('blocknotexist', 'debug', '', $blockname);
}
if ($dbversion >= $version) {
// something really wrong is going on in upgrade script
throw new downgrade_exception($component, $dbversion, $version);
}
set_config('version', $version, $component);
upgrade_log(UPGRADE_LOG_NORMAL, $component, 'Upgrade savepoint reached');
// reset upgrade timeout to default
upgrade_set_timeout();
core_upgrade_time::record_savepoint($version);
// this is a safe place to stop upgrades if user aborts page loading
if ($allowabort and connection_aborted()) {
die;
}
upgrade_plugin_savepoint($result, $version, 'block', $blockname, $allowabort);
}
/**
* Plugins upgrade savepoint, marks end of blocks upgrade blocks
* Plugins upgrade savepoint, marks end of plugin upgrade blocks
* It stores plugin version, resets upgrade timeout
* and abort upgrade if user cancels page loading.
*
* @category upgrade
* @param bool $result false if upgrade step failed, true if completed
* @param string or float $version main version
* @param string|float $version main version
* @param string $type The type of the plugin.
* @param string $plugin The name of the plugin.
* @param bool $allowabort allow user to abort script execution here
* @return void
*/
function upgrade_plugin_savepoint($result, $version, $type, $plugin, $allowabort=true) {
global $DB;
@ -480,6 +417,11 @@ function upgrade_plugin_savepoint($result, $version, $type, $plugin, $allowabort
throw new upgrade_exception($component, $version);
}
// Ensure we're dealing with a real component.
if (core_component::get_component_directory($component) === null) {
throw new moodle_exception('pluginnotexist', 'error', '', $component);
}
$dbversion = $DB->get_field('config_plugins', 'value', array('plugin'=>$component, 'name'=>'version'));
if ($dbversion >= $version) {