mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-74905 upgrade: remove all the < 3.11.0 upgrade steps
Note that, despite the commit message, this is not possible. Moodle 3.11.0 (and 3.10.0) were developed in parallel with Moodle 4.0, and when they were released, the master branch had already diverged, so the master branch does not contain the comment lines: "// Automatically generated Moodle v3.11.0 release upgrade line" And they are needed to know which parts of the upgrade are safe to delete. So we only proceed to delete all those steps from lib/db/upgrade.php which version is known to be < 2021051708 (v3.11.8), master ones will be, always bigger than that. We don't touch plugin upgrade scripts because they may have different versions, not 100% matching the 2021051708 rule, so there will be an excess of steps there. Note this is not a big problem, just a few more steps will be skipped and that's all. Whenever we bump the Moodle requirements again (to Moodle 4.0 or up), the lines will be back and we'll be able to safely remove all the steps before them. See previous Moodle requirements issues as example. The upgrade steps deleted by this commit weren't using any stuff from upgradelib, tasks..., so there isn't anything else to be removed but the core steps themselves. Also includes an upgrade step to prevent upgrading from any version < 2021051708 (v3.11.8) as anti-cheating measure.
This commit is contained in:
parent
c66dc59131
commit
fa269897c7
@ -92,112 +92,13 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
|
||||
|
||||
// Always keep this upgrade step with version being the minimum
|
||||
// allowed version to upgrade from (v3.9.0 right now).
|
||||
if ($oldversion < 2020061500) {
|
||||
// allowed version to upgrade from (v3.11.8 right now).
|
||||
if ($oldversion < 2021051708) {
|
||||
// Just in case somebody hacks upgrade scripts or env, we really can not continue.
|
||||
echo("You need to upgrade to 3.9.x or higher first!\n");
|
||||
echo("You need to upgrade to 3.11.8 or higher first!\n");
|
||||
exit(1);
|
||||
// Note this savepoint is 100% unreachable, but needed to pass the upgrade checks.
|
||||
upgrade_main_savepoint(true, 2020061500);
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.9.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2020061500.02) {
|
||||
// Update default digital age consent map according to the current legislation on each country.
|
||||
|
||||
// The default age of digital consent map for 38 and below.
|
||||
$oldageofdigitalconsentmap = implode(PHP_EOL, [
|
||||
'*, 16',
|
||||
'AT, 14',
|
||||
'ES, 14',
|
||||
'US, 13'
|
||||
]);
|
||||
|
||||
// Check if the current age of digital consent map matches the old one.
|
||||
if (get_config('moodle', 'agedigitalconsentmap') === $oldageofdigitalconsentmap) {
|
||||
// If the site is still using the old defaults, upgrade to the new default.
|
||||
$ageofdigitalconsentmap = implode(PHP_EOL, [
|
||||
'*, 16',
|
||||
'AT, 14',
|
||||
'BE, 13',
|
||||
'BG, 14',
|
||||
'CY, 14',
|
||||
'CZ, 15',
|
||||
'DK, 13',
|
||||
'EE, 13',
|
||||
'ES, 14',
|
||||
'FI, 13',
|
||||
'FR, 15',
|
||||
'GB, 13',
|
||||
'GR, 15',
|
||||
'IT, 14',
|
||||
'LT, 14',
|
||||
'LV, 13',
|
||||
'MT, 13',
|
||||
'NO, 13',
|
||||
'PT, 13',
|
||||
'SE, 13',
|
||||
'US, 13'
|
||||
]);
|
||||
set_config('agedigitalconsentmap', $ageofdigitalconsentmap);
|
||||
}
|
||||
|
||||
upgrade_main_savepoint(true, 2020061500.02);
|
||||
}
|
||||
|
||||
if ($oldversion < 2020062600.01) {
|
||||
// Add index to the token field in the external_tokens table.
|
||||
$table = new xmldb_table('external_tokens');
|
||||
$index = new xmldb_index('token', XMLDB_INDEX_NOTUNIQUE, ['token']);
|
||||
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
upgrade_main_savepoint(true, 2020062600.01);
|
||||
}
|
||||
|
||||
if ($oldversion < 2020071100.01) {
|
||||
// Clean up completion criteria records referring to NULL course prerequisites.
|
||||
$select = 'criteriatype = :type AND courseinstance IS NULL';
|
||||
$params = ['type' => 8]; // COMPLETION_CRITERIA_TYPE_COURSE.
|
||||
|
||||
$DB->delete_records_select('course_completion_criteria', $select, $params);
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2020071100.01);
|
||||
}
|
||||
|
||||
if ($oldversion < 2020072300.01) {
|
||||
// Restore and set the guest user if it has been previously removed via GDPR, or set to an nonexistent
|
||||
// user account.
|
||||
$currentguestuser = $DB->get_record('user', array('id' => $CFG->siteguest));
|
||||
|
||||
if (!$currentguestuser) {
|
||||
if (!$guest = $DB->get_record('user', array('username' => 'guest', 'mnethostid' => $CFG->mnet_localhost_id))) {
|
||||
// Create a guest user account.
|
||||
$guest = new stdClass();
|
||||
$guest->auth = 'manual';
|
||||
$guest->username = 'guest';
|
||||
$guest->password = hash_internal_user_password('guest');
|
||||
$guest->firstname = get_string('guestuser');
|
||||
$guest->lastname = ' ';
|
||||
$guest->email = 'root@localhost';
|
||||
$guest->description = get_string('guestuserinfo');
|
||||
$guest->mnethostid = $CFG->mnet_localhost_id;
|
||||
$guest->confirmed = 1;
|
||||
$guest->lang = $CFG->lang;
|
||||
$guest->timemodified= time();
|
||||
$guest->id = $DB->insert_record('user', $guest);
|
||||
}
|
||||
// Set the guest user.
|
||||
set_config('siteguest', $guest->id);
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2020072300.01);
|
||||
upgrade_main_savepoint(true, 2021051708);
|
||||
}
|
||||
|
||||
if ($oldversion < 2021052500.01) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user