Skip to content

Commit

Permalink
MDL-78496 upgrade: remove all the < 4.1.0 upgrade steps
Browse files Browse the repository at this point in the history
Also includes an upgrade step to prevent upgrading from any
version < 2021112802 (v4.1.0) as anti-cheating measure.
  • Loading branch information
andrewnicols committed Nov 17, 2023
1 parent 5c68be9 commit 545b36c
Show file tree
Hide file tree
Showing 121 changed files with 4 additions and 6,293 deletions.
14 changes: 0 additions & 14 deletions admin/tool/cohortroles/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@
function xmldb_tool_cohortroles_upgrade($oldversion) {
global $DB;

if ($oldversion < 2020020600) {
// Delete any tool_cohortroles mappings for roles which no longer exist.
$DB->delete_records_select('tool_cohortroles', 'roleid NOT IN (SELECT id FROM {role})');

// Cohortroles savepoint reached.
upgrade_plugin_savepoint(true, 2020020600, 'tool', 'cohortroles');
}

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
8 changes: 0 additions & 8 deletions admin/tool/customlang/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@
defined('MOODLE_INTERNAL') || die();

function xmldb_tool_customlang_upgrade($oldversion) {
global $CFG;

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
49 changes: 0 additions & 49 deletions admin/tool/dataprivacy/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,55 +35,6 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {

$dbman = $DB->get_manager();

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2020061501) {

// Define field commentsformat to be added to tool_dataprivacy_request.
$table = new xmldb_table('tool_dataprivacy_request');
$field = new xmldb_field('commentsformat', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'comments');

// Conditionally launch add field commentsformat.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

// Define field dpocommentformat to be added to tool_dataprivacy_request.
$field = new xmldb_field('dpocommentformat', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'dpocomment');

// Conditionally launch add field dpocommentformat.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

// Define field systemapproved to be added to tool_dataprivacy_request.
$field = new xmldb_field('systemapproved', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'dpocommentformat');

// Conditionally launch add field systemapproved.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

// Dataprivacy savepoint reached.
upgrade_plugin_savepoint(true, 2020061501, 'tool', 'dataprivacy');
}

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2022053000) {

// Define key usermodified (foreign) to be added to tool_dataprivacy_purposerole.
$table = new xmldb_table('tool_dataprivacy_purposerole');
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);

// Launch add key usermodified.
$dbman->add_key($table, $key);

// Dataprivacy savepoint reached.
upgrade_plugin_savepoint(true, 2022053000, 'tool', 'dataprivacy');
}

// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
8 changes: 0 additions & 8 deletions admin/tool/log/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@
* @return bool always true
*/
function xmldb_tool_log_upgrade($oldversion) {
global $CFG;

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
8 changes: 0 additions & 8 deletions admin/tool/log/store/database/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
defined('MOODLE_INTERNAL') || die();

function xmldb_logstore_database_upgrade($oldversion) {
global $CFG;

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
35 changes: 0 additions & 35 deletions admin/tool/log/store/standard/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,6 @@
defined('MOODLE_INTERNAL') || die();

function xmldb_logstore_standard_upgrade($oldversion) {
global $CFG, $DB;

require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions.

$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2022053000) {
// Define index relateduserid (not unique) to be added to logstore_standard_log.
$table = new xmldb_table('logstore_standard_log');

// Launch add key userid.
$key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
$dbman->add_key($table, $key);

// Launch add key courseid.
$key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']);
$dbman->add_key($table, $key);

// Launch add key realuserid.
$key = new xmldb_key('realuserid', XMLDB_KEY_FOREIGN, ['realuserid'], 'user', ['id']);
$dbman->add_key($table, $key);

// Launch add key relateduserid.
$key = new xmldb_key('relateduserid', XMLDB_KEY_FOREIGN, ['relateduserid'], 'user', ['id']);
$dbman->add_key($table, $key);

// Standard savepoint reached.
upgrade_plugin_savepoint(true, 2022053000, 'logstore', 'standard');
}

// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
8 changes: 0 additions & 8 deletions admin/tool/mobile/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@
* @return bool always true
*/
function xmldb_tool_mobile_upgrade($oldversion) {
global $CFG;

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
38 changes: 0 additions & 38 deletions admin/tool/monitor/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,6 @@
* @return bool always true
*/
function xmldb_tool_monitor_upgrade($oldversion) {
global $CFG, $DB;

require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions.

$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2022053000) {

// Define key courseid (foreign) to be added to tool_monitor_events.
$table = new xmldb_table('tool_monitor_events');
$key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']);

// Launch add key courseid.
$dbman->add_key($table, $key);

// Define key contextid (foreign) to be added to tool_monitor_events.
$table = new xmldb_table('tool_monitor_events');
$key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']);

// Launch add key contextid.
$dbman->add_key($table, $key);

// Define key contextinstanceid (foreign) to be added to tool_monitor_events.
$table = new xmldb_table('tool_monitor_events');
$key = new xmldb_key('contextinstanceid', XMLDB_KEY_FOREIGN, ['contextinstanceid'], 'context', ['instanceid']);

// Launch add key contextinstanceid.
$dbman->add_key($table, $key);

// Monitor savepoint reached.
upgrade_plugin_savepoint(true, 2022053000, 'tool', 'monitor');
}

// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
118 changes: 0 additions & 118 deletions admin/tool/moodlenet/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,124 +31,6 @@
* @return bool always true
*/
function xmldb_tool_moodlenet_upgrade(int $oldversion) {
global $CFG, $DB;
if ($oldversion < 2020060500) {

// Grab some of the old settings.
$categoryname = get_config('tool_moodlenet', 'profile_category');
$profilefield = get_config('tool_moodlenet', 'profile_field_name');

// Master version only!

// Find out if we have a custom profile field for moodle.net.
$sql = "SELECT f.*
FROM {user_info_field} f
JOIN {user_info_category} c ON c.id = f.categoryid and c.name = :categoryname
WHERE f.shortname = :name";

$params = [
'categoryname' => $categoryname,
'name' => $profilefield
];

$record = $DB->get_record_sql($sql, $params);

if (!empty($record)) {
$userentries = $DB->get_recordset('user_info_data', ['fieldid' => $record->id]);
$recordstodelete = [];
foreach ($userentries as $userentry) {
$data = (object) [
'id' => $userentry->userid,
'moodlenetprofile' => $userentry->data
];
$DB->update_record('user', $data, true);
$recordstodelete[] = $userentry->id;
}
$userentries->close();

// Remove the user profile data, fields, and category.
$DB->delete_records_list('user_info_data', 'id', $recordstodelete);
$DB->delete_records('user_info_field', ['id' => $record->id]);
$DB->delete_records('user_info_category', ['name' => $categoryname]);
unset_config('profile_field_name', 'tool_moodlenet');
unset_config('profile_category', 'tool_moodlenet');
}

upgrade_plugin_savepoint(true, 2020060500, 'tool', 'moodlenet');
}

if ($oldversion < 2020061501) {
// Change the domain.
$defaultmoodlenet = get_config('tool_moodlenet', 'defaultmoodlenet');

if ($defaultmoodlenet === 'https://home.moodle.net') {
set_config('defaultmoodlenet', 'https://moodle.net', 'tool_moodlenet');
}

// Change the name.
$defaultmoodlenetname = get_config('tool_moodlenet', 'defaultmoodlenetname');

if ($defaultmoodlenetname === 'Moodle HQ MoodleNet') {
set_config('defaultmoodlenetname', 'MoodleNet Central', 'tool_moodlenet');
}

upgrade_plugin_savepoint(true, 2020061501, 'tool', 'moodlenet');
}

if ($oldversion < 2020061502) {
// Disable the MoodleNet integration by default till further notice.
set_config('enablemoodlenet', 0, 'tool_moodlenet');

upgrade_plugin_savepoint(true, 2020061502, 'tool', 'moodlenet');
}

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2022021600) {
// This is a special case for if MoodleNet integration has never been enabled,
// or if defaultmoodlenet is not set for whatever reason.
if (!get_config('tool_moodlenet', 'defaultmoodlenet')) {
set_config('defaultmoodlenet', 'https://moodle.net', 'tool_moodlenet');
set_config('defaultmoodlenetname', get_string('defaultmoodlenetnamevalue', 'tool_moodlenet'), 'tool_moodlenet');
}

// Enable MoodleNet and set it to display on activity chooser footer.
// But only do this if we know for sure that the default MoodleNet is a working one.
if (get_config('tool_moodlenet', 'defaultmoodlenet') == 'https://moodle.net') {
set_config('enablemoodlenet', '1', 'tool_moodlenet');
set_config('activitychooseractivefooter', 'tool_moodlenet');

// Use an adhoc task to send a notification to admin stating MoodleNet is automatically enabled after upgrade.
$notificationtask = new tool_moodlenet\task\send_enable_notification();
core\task\manager::queue_adhoc_task($notificationtask);
}

upgrade_plugin_savepoint(true, 2022021600, 'tool', 'moodlenet');
}

if ($oldversion < 2022021601) {

$selectsql = "moodlenetprofile IS NOT NULL AND moodlenetprofile != ''";

// If there are any users with MoodleNet profile set.
if ($DB->count_records_select('user', $selectsql)) {
// Remove the value set for the MoodleNet profile as this format can no longer be used to authenticate
// MoodleNet users.
$DB->set_field_select('user', 'moodlenetprofile', '', $selectsql);

// Use an adhoc task to send a notification to admin stating that the user data related to the linked
// MoodleNet profiles has been removed.
$notificationtask = new tool_moodlenet\task\send_mnet_profiles_data_removed_notification();
core\task\manager::queue_adhoc_task($notificationtask);
}

upgrade_plugin_savepoint(true, 2022021601, 'tool', 'moodlenet');
}

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
8 changes: 0 additions & 8 deletions admin/tool/policy/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@
* @return bool
*/
function xmldb_tool_policy_upgrade($oldversion) {
global $DB;

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
Loading

0 comments on commit 545b36c

Please sign in to comment.