MDL-69049 tool_dataprivacy: Add possibly missing comment format columns

The earlier CONTRIB plugin versions of the tool (<33.2.0, <34.2.0) were
missing the following columns in the data requests table:
* commentsformat
* dpocommentformat
And the upgrade scripts for the merged tool failed in
Moodle 3.3.8+/3.3.0+ failed to add these columns.
So a site which uses the CONTRIB plugin and eventually upgrading to 3.9
will encounter an error during upgrade because of the missing
dpocommentformat column.
This commit is contained in:
Jun Pataleta 2020-06-15 22:47:22 +08:00
parent a51797cc0e
commit 3484f3e4b5
2 changed files with 23 additions and 7 deletions

View File

@ -322,10 +322,29 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {
// Automatically generated Moodle v3.8.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2019121700) {
// 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.
$table = new xmldb_table('tool_dataprivacy_request');
$field = new xmldb_field('systemapproved', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'dpocommentformat');
// Conditionally launch add field systemapproved.
@ -334,11 +353,8 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {
}
// Dataprivacy savepoint reached.
upgrade_plugin_savepoint(true, 2019121700, 'tool', 'dataprivacy');
upgrade_plugin_savepoint(true, 2020061501, 'tool', 'dataprivacy');
}
// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.
return true;
}

View File

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2020061500;
$plugin->version = 2020061501;
$plugin->requires = 2020060900;
$plugin->component = 'tool_dataprivacy';