From 3484f3e4b52d55553e1e8000372bcddc635fc5c1 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 15 Jun 2020 22:47:22 +0800 Subject: [PATCH] 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. --- admin/tool/dataprivacy/db/upgrade.php | 28 +++++++++++++++++++++------ admin/tool/dataprivacy/version.php | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/admin/tool/dataprivacy/db/upgrade.php b/admin/tool/dataprivacy/db/upgrade.php index e166cf6f666..30a988195a5 100644 --- a/admin/tool/dataprivacy/db/upgrade.php +++ b/admin/tool/dataprivacy/db/upgrade.php @@ -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; } diff --git a/admin/tool/dataprivacy/version.php b/admin/tool/dataprivacy/version.php index 7925e88a031..1df48bcb7f5 100644 --- a/admin/tool/dataprivacy/version.php +++ b/admin/tool/dataprivacy/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2020061500; +$plugin->version = 2020061501; $plugin->requires = 2020060900; $plugin->component = 'tool_dataprivacy';