Permalink
Browse files

MDL-32543 (backport) Make sure the action and url fields of log table…

… have correct sizes
  • Loading branch information...
1 parent 263f3b1 commit 84e991ac778603ae4bfa1ef4147cb76b2d996acc @danielneis danielneis committed May 12, 2014
Showing with 30 additions and 1 deletion.
  1. +29 −0 lib/db/upgrade.php
  2. +1 −1 version.php
View
@@ -2361,5 +2361,34 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013051405.10);
}
+ // MDL-32543 Make sure that the log table has correct length for action and url fields.
+ if ($oldversion < 2013051406.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, 2013051406.01);
+ }
+
return true;
}
View
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2013051406.00; // 20130514 = branching date YYYYMMDD - do not modify!
+$version = 2013051406.01; // 20130514 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches
// .XX = incremental changes

0 comments on commit 84e991a

Please sign in to comment.