Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Migrating latin1 to utf8 in Vanilla 1.0.3
Help!
Vanilla was installed in an older server, with an older MySQL, and an older phpMyAdmin (which did not support UTF-8). Even though my forum uses Esperanto characters a lot (ĉ, Å, Ä, Ä¥, ĵ, Å), I had everything set in its default of 'latin1', and even though if I looked at my database via phpMyAdmin it all looked like garbled text, it still worked and displayed fine in the forum. I kept the forums up-to-date, and was running version 1.0.3 of Vanilla with several extensions, without any problems.
A couple of days ago I upgraded our account to a new server, which has a newer MySQL, and a newer phpMyAdmin, supporting UTF-8 in full. I decided to change everything over to UTF-8, and after having read several of the discussions in here, thought that I'd do the migration the 'clever way':
1) In the old server, with the old phpMyAdmin using latin1, I downloaded a full sql export of the entire database.
2) Using a programmer's text editor (TextMate), I opened the sql export file, and got the program to automatically re-read all characters as UTF-8. It worked! All international characters displayed perfectly! I saved the file as UTF-8 text.
3) Went into the NEW phpMyAdmin, setup the new database, made sure its collation is UTF-8, and that the phpMyAdmin interface is also UTF-8. Imported the converted backup into the database, and voilá! In phpMyAdmin, the data is all there, and all the characters display perfectly!
So, I opened the forum, now running from the new database, to test it out. But... the Esperanto characters are NOT showing - all I'm getting is the "?" instead.
I do not understand, as from what I've read in previous postings, my entire system should be native UTF-8. Obviously, something isn't. I don't understand. Please, help!
0
This discussion has been closed.
Comments
For those of us who have 1.0.3 installed, there is only one modification necessary, in order to make Vanilla fully utf-8 savvy. You must edit the file "Vanilla/library/Framework/Framework.Class.MySQL.php" in 2 places, as describe in the previously mentioned discussion. The poster actually includes 2 more edits, to installation files, which do not seem to be necessary, as Mark has already included *those* ones in the latest (1.0.3) version of Vanilla.
So, for future reference, using version 1.0.3 of Vanilla, the easiest way to migrate your entire system from latin1 (or something else) to utf-8, is:
1) using phpMyAdmin, export your entire database to an .sql file
2) using a programmer's text editor (TextMate/TextWrangler/Smultron), translate the file (until you see the characters displayed correctly), then save the file using utf-8 encoding.
3) make a new database in phpMyAdmin, and make sure it is utf-8 encoded (ie., it is using "utf8_general_ci" collation).
4) apply the patch described above to a single file in your 1.0.3 installation
5) browse the site
It should work, and all your international characters should display correctly, both in Vanilla, as well as in phpMyAdmin.
Sorry I didn't read this discussion in time to help you, but you sorted it our by yourself, the right way.
@Ares:
Will work as long as nobody will try to post text in non latin language, say Russian or Arab or anything else.
dammit.
Can I help in some way?
If you want to patch your install before Mark release 1.1 (is it worthwhile?) here is a patch. It's different from the posted original because it is in a central place, rather than in several init_* file.
The file to patch is Library/Framework/Framework.Class.MySQL.php.
function GetConnection() { if (!$this->Connection) { if (!function_exists('mysql_connect')) $this->Context->ErrorManager->AddError($this->Context, $this->Name, 'GetConnection', 'You do not appear to have MySQL enabled for PHP.'); $this->Connection = @mysql_connect($this->Context->Configuration['DATABASE_HOST'], $this->Context->Configuration['DATABASE_USER'], $this->Context->Configuration['DATABASE_PASSWORD']); @mysql_query("SET NAMES 'utf8'"); //this line is UTF-8 patch
and
function GetFarmConnection() { if ($this->FarmConnection) { return $this->FarmConnection; } elseif ($this->Context->Configuration['FARM_DATABASE_HOST'] != '') { if (!function_exists('mysql_connect')) $this->Context->ErrorManager->AddError($this->Context, $this->Name, 'GetConnection', 'You do not appear to have MySQL enabled for PHP.'); $this->FarmConnection = @mysql_connect($this->Context->Configuration['FARM_DATABASE_HOST'], $this->Context->Configuration['FARM_DATABASE_USER'], $this->Context->Configuration['FARM_DATABASE_PASSWORD']); @mysql_query("SET NAMES 'utf8'"); //this line is UTF-8 patch
In each code snipet the last line is the only mod.
But admins of boards running in the "weird" or "worst" case (referring to my own term in this post) are on their own to clean things up.
The weird case is rather simple to sort out, following a path outlined by Icouto in this thread, at the cost of a base re-install.
The "worst" case is more cryptic. Incorrect characters bust be read as utf-8 (looking bad), converted to latin1 and saved (still looking bad) then read again as utf-8 (should looks ok).
Users running MySQL < 4.1 are either all latin1 (OK) or weird.
Mysql >= 4.1 are weird if database is set up as latin1 or worst if utf-8.
Not to mention that Mysql charset cant be setup at different level, global, table, column or even literal data, and then there may be mixed case.
I've also upgraded the installer and upgrader scripts so that they make the db and it's tables utf8 if it is above mysql 4.1 - they will automatically save this variable in the conf/database.php file as well.
The only thing I did differently was to make the default value for the DATABASE_CHARACTER_ENCODING setting blank. I did this so that existing working copies of Vanilla wouldn't break when they upgrade to Vanilla 1.1.
Max, I was hoping you could write a page in the wiki about what to do if you encounter problems with character encoding in Vanilla. You just know so much more about it than me. If you are interested, I'd really appreciate it.
But when I upgraded my forum on my online server (with MySQL 5.0.18-Debian_3.dotdeb.1) the characters were all garbled, while my database DEFAULT_CHARACTER_SET_NAME and DEFAULT_COLLATION_NAME are the same as in on my local machine.
How come? Because the newer MySQL version?
I fixed this by replacing all 'utf-8' to 'ISO-8859-1' in the Vanilla 1.1 upgrade files.
Your site does not seem to be using Vanilla but the problem is of the same nature as soon as PHP application use MySQL databases.