Commit 77342b96 authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

MDL-69308 upgrade: remove all the < 3.6.0 upgrade steps

This just deletes all the upgrade steps previous to 3.6.0. Some
small adjustments, like tweaking globals can also be applied
when needed.

Also includes an upgrade step to prevent upgrading from any
version < 2018120300 (v3.6.0) as anti-cheating measure.

Note that in this case, there wasn't any case of upgradelib
functions being used, hence we haven't to deprecate/remove
anything in codebase. When there is such a need, that is done
in separate commits (one for each function) and documented here.

See MDL-65809 commits for an example removing/deprecating a
good number of functions.
parent cc0e5e22
......@@ -29,9 +29,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_tool_customlang_upgrade($oldversion) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -35,284 +35,6 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {
$dbman = $DB->get_manager();
if ($oldversion < 2018051405) {
// Define table tool_dataprivacy_ctxexpired to be created.
$table = new xmldb_table('tool_dataprivacy_ctxexpired');
// Adding fields to table tool_dataprivacy_ctxexpired.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('status', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
$table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
// Adding keys to table tool_dataprivacy_ctxexpired.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('contextid', XMLDB_KEY_FOREIGN_UNIQUE, array('contextid'), 'context', array('id'));
// Conditionally launch create table for tool_dataprivacy_ctxexpired.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Define table tool_dataprivacy_contextlist to be created.
$table = new xmldb_table('tool_dataprivacy_contextlist');
// Adding fields to table tool_dataprivacy_contextlist.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('component', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
// Adding keys to table tool_dataprivacy_contextlist.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
// Conditionally launch create table for tool_dataprivacy_contextlist.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Define table tool_dataprivacy_ctxlst_ctx to be created.
$table = new xmldb_table('tool_dataprivacy_ctxlst_ctx');
// Adding fields to table tool_dataprivacy_ctxlst_ctx.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('contextlistid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('status', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
// Adding keys to table tool_dataprivacy_ctxlst_ctx.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('contextlistid', XMLDB_KEY_FOREIGN, array('contextlistid'), 'tool_dataprivacy_contextlist', array('id'));
// Conditionally launch create table for tool_dataprivacy_ctxlst_ctx.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Define table tool_dataprivacy_rqst_ctxlst to be created.
$table = new xmldb_table('tool_dataprivacy_rqst_ctxlst');
// Adding fields to table tool_dataprivacy_rqst_ctxlst.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('requestid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('contextlistid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
// Adding keys to table tool_dataprivacy_rqst_ctxlst.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('requestid', XMLDB_KEY_FOREIGN, array('requestid'), 'tool_dataprivacy_request', array('id'));
$table->add_key('contextlistid', XMLDB_KEY_FOREIGN, array('contextlistid'), 'tool_dataprivacy_contextlist', array('id'));
$table->add_key('request_contextlist', XMLDB_KEY_UNIQUE, array('requestid', 'contextlistid'));
// Conditionally launch create table for tool_dataprivacy_rqst_ctxlst.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Define field lawfulbases to be added to tool_dataprivacy_purpose.
$table = new xmldb_table('tool_dataprivacy_purpose');
// It is a required field. We initially define and add it as null and later update it to XMLDB_NOTNULL.
$field = new xmldb_field('lawfulbases', XMLDB_TYPE_TEXT, null, null, null, null, null, 'descriptionformat');
// Conditionally launch add field lawfulbases.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
// Set a kind-of-random value to lawfulbasis field.
$DB->set_field('tool_dataprivacy_purpose', 'lawfulbases', 'gdpr_art_6_1_a');
// We redefine it now as not null.
$field = new xmldb_field('lawfulbases', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null, 'descriptionformat');
// Launch change of nullability for field lawfulbases.
$dbman->change_field_notnull($table, $field);
}
// Define field sensitivedatareasons to be added to tool_dataprivacy_purpose.
$table = new xmldb_table('tool_dataprivacy_purpose');
$field = new xmldb_field('sensitivedatareasons', XMLDB_TYPE_TEXT, null, null, null, null, null, 'lawfulbases');
// Conditionally launch add field sensitivedatareasons.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Dataprivacy savepoint reached.
upgrade_plugin_savepoint(true, 2018051405, 'tool', 'dataprivacy');
}
if ($oldversion < 2018051406) {
// Update completed delete requests to new delete status.
$query = "UPDATE {tool_dataprivacy_request}
SET status = :setstatus
WHERE type = :type
AND status = :wherestatus";
$params = array(
'setstatus' => 10, // Request deleted.
'type' => 2, // Delete type.
'wherestatus' => 5, // Request completed.
);
$DB->execute($query, $params);
// Update completed data export requests to new download ready status.
$params = array(
'setstatus' => 8, // Request download ready.
'type' => 1, // export type.
'wherestatus' => 5, // Request completed.
);
$DB->execute($query, $params);
upgrade_plugin_savepoint(true, 2018051406, 'tool', 'dataprivacy');
}
if ($oldversion < 2018082100) {
// Changing precision of field status on table tool_dataprivacy_request to (2).
$table = new xmldb_table('tool_dataprivacy_request');
$field = new xmldb_field('status', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'requestedby');
// Launch change of precision for field status.
$dbman->change_field_precision($table, $field);
// Dataprivacy savepoint reached.
upgrade_plugin_savepoint(true, 2018082100, 'tool', 'dataprivacy');
}
if ($oldversion < 2018100401) {
// Define table tool_dataprivacy_purposerole to be created.
$table = new xmldb_table('tool_dataprivacy_purposerole');
// Adding fields to table tool_dataprivacy_purposerole.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('purposeid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('roleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('lawfulbases', XMLDB_TYPE_TEXT, null, null, null, null, null);
$table->add_field('sensitivedatareasons', XMLDB_TYPE_TEXT, null, null, null, null, null);
$table->add_field('retentionperiod', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('protected', XMLDB_TYPE_INTEGER, '1', null, null, null, null);
$table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
// Adding keys to table tool_dataprivacy_purposerole.
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
$table->add_key('purposepurposeid', XMLDB_KEY_FOREIGN, ['purposeid'], 'tool_dataprivacy_purpose', ['id']);
$table->add_key('puproseroleid', XMLDB_KEY_FOREIGN, ['roleid'], 'role', ['id']);
// Adding indexes to table tool_dataprivacy_purposerole.
$table->add_index('purposerole', XMLDB_INDEX_UNIQUE, ['purposeid', 'roleid']);
// Conditionally launch create table for tool_dataprivacy_purposerole.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Update the ctxexpired table.
$table = new xmldb_table('tool_dataprivacy_ctxexpired');
// Add the unexpiredroles field.
$field = new xmldb_field('unexpiredroles', XMLDB_TYPE_TEXT, null, null, null, null, null, 'contextid');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$DB->set_field('tool_dataprivacy_ctxexpired', 'unexpiredroles', '');
// Add the expiredroles field.
$field = new xmldb_field('expiredroles', XMLDB_TYPE_TEXT, null, null, null, null, null, 'unexpiredroles');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$DB->set_field('tool_dataprivacy_ctxexpired', 'expiredroles', '');
// Add the defaultexpired field.
$field = new xmldb_field('defaultexpired', XMLDB_TYPE_INTEGER, '1', null, null, null, '1', 'expiredroles');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Change the default for the expired field to be empty.
$field = new xmldb_field('defaultexpired', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'expiredroles');
$dbman->change_field_default($table, $field);
// Prevent hte field from being nullable.
$field = new xmldb_field('defaultexpired', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, 'expiredroles');
$dbman->change_field_notnull($table, $field);
// Dataprivacy savepoint reached.
upgrade_plugin_savepoint(true, 2018100401, 'tool', 'dataprivacy');
}
if ($oldversion < 2018100406) {
// Define field sensitivedatareasons to be added to tool_dataprivacy_purpose.
$table = new xmldb_table('tool_dataprivacy_request');
$field = new xmldb_field('creationmethod', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, 0, 'timemodified');
// Conditionally launch add field sensitivedatareasons.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Dataprivacy savepoint reached.
upgrade_plugin_savepoint(true, 2018100406, 'tool', 'dataprivacy');
}
if ($oldversion < 2018110700) {
// Define table tool_dataprivacy_ctxlst_ctx to be dropped.
$table = new xmldb_table('tool_dataprivacy_ctxlst_ctx');
// Conditionally launch drop table for tool_dataprivacy_ctxlst_ctx.
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
// Define table tool_dataprivacy_rqst_ctxlst to be dropped.
$table = new xmldb_table('tool_dataprivacy_rqst_ctxlst');
// Conditionally launch drop table for tool_dataprivacy_rqst_ctxlst.
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
// Define table tool_dataprivacy_contextlist to be dropped.
$table = new xmldb_table('tool_dataprivacy_contextlist');
// Conditionally launch drop table for tool_dataprivacy_contextlist.
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
// Update all requests which were in states Pending, or Pre-Processing, to Awaiting approval.
$DB->set_field('tool_dataprivacy_request', 'status', 2, ['status' => 0]);
$DB->set_field('tool_dataprivacy_request', 'status', 2, ['status' => 1]);
// Remove the old initiate_data_request_task adhoc entries.
$DB->delete_records('task_adhoc', ['classname' => '\tool_dataprivacy\task\initiate_data_request_task']);
// Dataprivacy savepoint reached.
upgrade_plugin_savepoint(true, 2018110700, 'tool', 'dataprivacy');
}
if ($oldversion < 2018112500) {
// Delete orphaned data privacy requests.
$sql = "SELECT r.id
FROM {tool_dataprivacy_request} r LEFT JOIN {user} u ON r.userid = u.id
WHERE u.id IS NULL";
$orphaned = $DB->get_fieldset_sql($sql);
if ($orphaned) {
$DB->delete_records_list('tool_dataprivacy_request', 'id', $orphaned);
}
upgrade_plugin_savepoint(true, 2018112500, 'tool', 'dataprivacy');
}
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -33,9 +33,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_tool_log_upgrade($oldversion) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -27,9 +27,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_logstore_database_upgrade($oldversion) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -27,9 +27,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_logstore_standard_upgrade($oldversion) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -33,9 +33,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_tool_monitor_upgrade($oldversion) {
global $CFG, $DB;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -34,32 +34,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_tool_policy_upgrade($oldversion) {
global $DB;
$dbman = $DB->get_manager();
if ($oldversion < 2018082900) {
// Add field agreementstyle to the table tool_policy_versions.
$table = new xmldb_table('tool_policy_versions');
$field = new xmldb_field('agreementstyle', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0', 'policyid');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_plugin_savepoint(true, 2018082900, 'tool', 'policy');
}
if ($oldversion < 2018091800) {
// Add field "optional" to the table "tool_policy_versions".
$table = new xmldb_table('tool_policy_versions');
$field = new xmldb_field('optional', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0', 'agreementstyle');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_plugin_savepoint(true, 2018091800, 'tool', 'policy');
}
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -36,9 +36,6 @@ use tool_usertours\tour;
function xmldb_tool_usertours_upgrade($oldversion) {
global $CFG, $DB;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -32,9 +32,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_auth_cas_upgrade($oldversion) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -32,9 +32,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_auth_db_upgrade($oldversion) {
global $CFG, $DB;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -32,9 +32,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_auth_email_upgrade($oldversion) {
global $CFG, $DB;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -32,9 +32,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_auth_ldap_upgrade($oldversion) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -32,9 +32,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_auth_manual_upgrade($oldversion) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -32,9 +32,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_auth_mnet_upgrade($oldversion) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -32,9 +32,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_auth_none_upgrade($oldversion) {
global $CFG, $DB;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -35,9 +35,6 @@ function xmldb_auth_oauth2_upgrade($oldversion) {
$dbman = $DB->get_manager();
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -32,9 +32,6 @@ defined('MOODLE_INTERNAL') || die();
function xmldb_auth_shibboleth_upgrade($oldversion) {
global $CFG, $DB;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -45,9 +45,6 @@
function xmldb_block_badges_upgrade($oldversion, $block) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -45,9 +45,6 @@
function xmldb_block_calendar_month_upgrade($oldversion, $block) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
......@@ -45,9 +45,6 @@
function xmldb_block_calendar_upcoming_upgrade($oldversion, $block) {
global $CFG;
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment