From 6c8f7e1ce2ea7b4aad4c7b68dd166e41055f014f Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 15 Jun 2020 22:55:46 +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 7b2a9d8bc32..fd53f2956f9 100644 --- a/admin/tool/dataprivacy/db/upgrade.php +++ b/admin/tool/dataprivacy/db/upgrade.php @@ -322,5 +322,28 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) { // Automatically generated Moodle v3.8.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2019111801) { + + // 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, 2019111801, 'tool', 'dataprivacy'); + } + return true; } diff --git a/admin/tool/dataprivacy/version.php b/admin/tool/dataprivacy/version.php index 636f744cbf9..b25a10f33de 100644 --- a/admin/tool/dataprivacy/version.php +++ b/admin/tool/dataprivacy/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2019111800; +$plugin->version = 2019111801; $plugin->requires = 2019111200; // Moodle 3.5dev (Build 2018031600) and upwards. $plugin->component = 'tool_dataprivacy';