From d277c441daa59b0d5b64530541bba9fd06acded5 Mon Sep 17 00:00:00 2001 From: Daniel Neis Araujo Date: Tue, 18 Feb 2014 17:14:19 -0300 Subject: [PATCH] MDL-32543 Make sure the action and url fields of log table have correct sizes --- lib/db/upgrade.php | 30 ++++++++++++++++++++++++++++++ version.php | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index efb96fab730..5228a27787c 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3612,6 +3612,7 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2014041500.01); } + if ($oldversion < 2014050100.00) { // Fixing possible wrong MIME type for DigiDoc files. $extensions = array('%.bdoc', '%.cdoc', '%.ddoc'); @@ -3628,5 +3629,34 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2014050100.00); } + // MDL-32543 Make sure that the log table has correct length for action and url fields. + if ($oldversion < 2014051200.01) { + + $table = new xmldb_table('log'); + + $columns = $DB->get_columns('log'); + if ($columns['action']->max_length < 40) { + $index1 = new xmldb_index('course-module-action', XMLDB_INDEX_NOTUNIQUE, array('course', 'module', 'action')); + if ($dbman->index_exists($table, $index1)) { + $dbman->drop_index($table, $index1); + } + $index2 = new xmldb_index('action', XMLDB_INDEX_NOTUNIQUE, array('action')); + if ($dbman->index_exists($table, $index2)) { + $dbman->drop_index($table, $index2); + } + $field = new xmldb_field('action', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, 'cmid'); + $dbman->change_field_precision($table, $field); + $dbman->add_index($table, $index1); + $dbman->add_index($table, $index2); + } + + if ($columns['url']->max_length < 100) { + $field = new xmldb_field('url', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'action'); + $dbman->change_field_precision($table, $field); + } + + upgrade_main_savepoint(true, 2014051200.01); + } + return true; } diff --git a/version.php b/version.php index 89aa076d13b..b470c502aa2 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2014051200.00; // 20140512 = branching date YYYYMMDD - do not modify! +$version = 2014051200.01; // 20140512 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes.