From a326872b88d02ddf7cb0b6eb51f6a92aa5c323fd Mon Sep 17 00:00:00 2001 From: stronk7 Date: Thu, 15 May 2008 17:02:05 +0000 Subject: [PATCH] prevent NULL contents before field change (old servers can have this wrongly defined). MDL-14859 --- lib/db/upgrade.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 8a7f91575bd..fbe1268941a 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2970,6 +2970,11 @@ function xmldb_main_upgrade($oldversion=0) { if ($result && $oldversion < 2007101512) { notify('Increasing size of user idnumber field, this may take a while...', 'notifysuccess'); + /// Under MySQL and Postgres... detect old NULL contents and change them by correct empty string. MDL-14859 + if ($CFG->dbfamily == 'mysql' || $CFG->dbfamily == 'postgres') { + execute_sql("UPDATE {$CFG->prefix}user SET idnumber = '' WHERE idnumber IS NULL", true); + } + /// Define index idnumber (not unique) to be dropped form user $table = new XMLDBTable('user'); $index = new XMLDBIndex('idnumber');