From 3ab30c7f201e2277f8c99eac2083eeb6776e79f1 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 15 Jun 2020 23:41:19 +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 | 23 +++++++++++++++++++++++ admin/tool/dataprivacy/version.php | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/admin/tool/dataprivacy/db/upgrade.php b/admin/tool/dataprivacy/db/upgrade.php index 49cedd626f4..9d959ee16ea 100644 --- a/admin/tool/dataprivacy/db/upgrade.php +++ b/admin/tool/dataprivacy/db/upgrade.php @@ -319,5 +319,28 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) { // Automatically generated Moodle v3.7.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2019052001) { + + // 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); + } + + // Dataprivacy savepoint reached. + upgrade_plugin_savepoint(true, 2019052001, 'tool', 'dataprivacy'); + } + return true; } diff --git a/admin/tool/dataprivacy/version.php b/admin/tool/dataprivacy/version.php index 5b244011853..6f26f674131 100644 --- a/admin/tool/dataprivacy/version.php +++ b/admin/tool/dataprivacy/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2019052000; +$plugin->version = 2019052001; $plugin->requires = 2019051100; // Moodle 3.5dev (Build 2018031600) and upwards. $plugin->component = 'tool_dataprivacy';