From 223e7535206d6416191e38d947a4b9ed2f217495 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 16 Dec 2011 10:40:39 +0800 Subject: [PATCH] MDL-20245 grade: increased the size of the user_preferences value column and added php validation of the data going into that column Conflicts: lib/db/upgrade.php version.php --- lib/db/install.xml | 4 ++-- lib/db/upgrade.php | 13 +++++++++++++ lib/moodlelib.php | 3 +++ version.php | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index 8a9fdacd1ea..3d7b40e9ef6 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -788,7 +788,7 @@ - + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index a8a8f512f91..733bac4a002 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -6979,6 +6979,19 @@ FROM upgrade_main_savepoint(true, 2011120500.02); } + if ($oldversion < 2011120500.01) { + + // Changing precision of field value on table user_preferences to (1333) + $table = new xmldb_table('user_preferences'); + $field = new xmldb_field('value', XMLDB_TYPE_CHAR, '1333', null, XMLDB_NOTNULL, null, null, 'name'); + + // Launch change of precision for field value + $dbman->change_field_precision($table, $field); + + // Main savepoint reached + upgrade_main_savepoint(true, 2011120500.01); + } + return true; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index fb1a41027c7..61b4b44585b 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1652,6 +1652,9 @@ function set_user_preference($name, $value, $user = null) { throw new coding_exception('Invalid value in set_user_preference() call, arrays are not allowed'); } $value = (string)$value; + if (textlib::strlen($value) > 1333) { //value column maximum length is 1333 characters + throw new coding_exception('Invalid value in set_user_preference() call, value is is too long for the value column'); + } if (is_null($user)) { $user = $USER; diff --git a/version.php b/version.php index 86d0ad6aa9e..fcc0f57e4b7 100644 --- a/version.php +++ b/version.php @@ -30,7 +30,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2011120500.02; // 20111205 = branching date YYYYMMDD - do not modify! +$version = 2011120500.01; // 20111205 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches // .XX = incremental changes