MDL-36597 strip '_utf8' from all course.lang fields
authorPetr Škoda <commits@skodak.org>
Sat, 8 Dec 2012 14:49:56 +0000 (15:49 +0100)
committerPetr Škoda <commits@skodak.org>
Sat, 15 Dec 2012 10:18:59 +0000 (11:18 +0100)
lib/db/upgrade.php
version.php

index 91263db..92f7837 100644 (file)
@@ -985,5 +985,19 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2012062502.07);
     }
 
+    if ($oldversion < 2012062503.07) {
+        // Remove "_utf8" suffix from all langs in course table.
+        $langs = $DB->get_records_sql("SELECT DISTINCT lang FROM {course} WHERE lang LIKE ?", array('%_utf8'));
+
+        foreach ($langs as $lang=>$unused) {
+            $newlang = str_replace('_utf8', '', $lang);
+            $sql = "UPDATE {course} SET lang = :newlang WHERE lang = :lang";
+            $DB->execute($sql, array('newlang'=>$newlang, 'lang'=>$lang));
+        }
+
+        // Main savepoint reached.
+        upgrade_main_savepoint(true, 2012062503.07);
+    }
+
     return true;
 }
index 148b30c..95ae746 100644 (file)
@@ -30,7 +30,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 
-$version  = 2012062503.06;              // YYYYMMDD      = weekly release date of this DEV branch
+$version  = 2012062503.07;              // YYYYMMDD      = weekly release date of this DEV branch
                                         //         RR    = release increments - 00 in DEV branches
                                         //           .XX = incremental changes