]> git.mjollnir.org Git - moodle.git/commitdiff
prevent NULL contents before field change (old servers can have this wrongly defined...
authorstronk7 <stronk7>
Thu, 15 May 2008 17:03:49 +0000 (17:03 +0000)
committerstronk7 <stronk7>
Thu, 15 May 2008 17:03:49 +0000 (17:03 +0000)
lib/db/upgrade.php

index 00f7dc37fb26a6bcd5f4582e14d59c432e6540de..2ade4db902e6ca4ce256638830010c27808689d0 100644 (file)
@@ -87,6 +87,11 @@ function xmldb_main_upgrade($oldversion=0) {
     if ($result && $oldversion < 2008051201) {
         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');