]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #1181: UTF8 now correctly stored in database.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 7 Oct 2009 21:44:27 +0000 (21:44 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 7 Oct 2009 21:44:27 +0000 (21:44 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3514 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/database.php
engine/schema/upgrades/2009100701.sql [new file with mode: 0644]

index fa3a91fbb02374791f8aab055183ca63ed9e5c08..ff74c3655e2052ea88cafff753213c3c8d025f17 100644 (file)
@@ -56,6 +56,9 @@
                        if (!mysql_select_db($CONFIG->dbname, $dblink[$dblinkname]))
                                throw new DatabaseException(sprintf(elgg_echo('DatabaseException:NoConnect'), $CONFIG->dbname));
                        
+                       // Set DB for UTF8
+                               mysql_query("SET NAMES utf8");
+                               
                    // Set up cache
                        if ((!$DB_QUERY_CACHE) && (!$CONFIG->db_disable_query_cache)) 
                                $DB_QUERY_CACHE = new ElggStaticVariableCache('db_query_cache'); //array();
 
                register_elgg_event_handler('boot','system','init_db',0);
 
-?>
\ No newline at end of file
+?>
diff --git a/engine/schema/upgrades/2009100701.sql b/engine/schema/upgrades/2009100701.sql
new file mode 100644 (file)
index 0000000..f84096a
--- /dev/null
@@ -0,0 +1,19 @@
+SET NAMES utf8;
+
+REPLACE INTO `prefix_metastrings` (id, string) 
+       SELECT id, unhex(hex(convert(string using latin1))) 
+       FROM `prefix_metastrings`;
+
+REPLACE INTO `prefix_groups_entity` (guid, name, description) 
+       SELECT guid, unhex(hex(convert(name using latin1))), unhex(hex(convert(description using latin1)))
+       FROM `prefix_groups_entity`;
+
+REPLACE INTO `prefix_objects_entity` (guid, title, description)
+       SELECT guid, unhex(hex(convert(title using latin1))), unhex(hex(convert(description using latin1)))
+       FROM `prefix_objects_entity`;
+
+REPLACE INTO `prefix_users_entity` (guid, name, username, password, salt, email, language, code, 
+       banned, last_action, prev_last_action, last_login, prev_last_login)
+               SELECT guid, unhex(hex(convert(name using latin1))), username, password, salt, email, language, code,
+                       banned, last_action, prev_last_action, last_login, prev_last_login
+               FROM `prefix_users_entity`;