Ticket #2377 (new defect)

Opened 9 months ago

Last modified 3 months ago

Bug in displaying macronised characters

Reported by: emms Owned by: aoneil
Priority: medium Milestone: 2.4.0
Component: CMS - General Version: 2.2.2-rc2
Severity: medium effort / impact Keywords:
Cc: ischommer Hours:

Description

Hi, There is a problem with the display of macronised characters. Entered into the CMS they appear fine, but then render as ?? on the live site, and once the page is reloaded in the CMS they have changed to ?? in the CMS also.

Have done extensive testing to make sure that there is no problem with my webserver/database/website sending in the wrong charset - have eliminated all of this so it must be something in SS? :(

Please see this thread here for our attempts at deciphering the problem. http://www.silverstripe.com/site-builders-forum/flat/50517?start=0

This is important as we are creating a website for a Maori organisation who *need* these to display correctly.

Change History

Changed 9 months ago by sminnee

  • milestone set to 2.2.3 feature-lock

Can you please give us a link to your test server? For privacy you can email it to sam at silverstripe dot com.

Changed 9 months ago by sminnee

  • cc ischommer added

Okay - so I've worked out a solution to this. The other benefit of this change is that you can see your macrons properly inside phpMyAdmin.

In essence, we need to tell MySQL to recognise the character set we're using.

  • sapphire/core/model/MySQLDatabase.php

     
    3939        */ 
    4040       public function __construct($parameters) { 
    4141               $this->dbConn = mysql_connect($parameters['server'], $parameters['username'], $parameters['password']); 
     42               $this->query("SET CHARACTER SET 'utf8'"); 
     43               $this->query("SET NAMES 'utf8'"); 
    4244               $this->active = mysql_select_db($parameters['database'], $this->dbConn); 
    4345               $this->database = $parameters['database']; 
    4446               if(!$this->dbConn) { 

But there's a big problem with this: if we blindly apply it to the mainline trunk, we will corrupt everyone's data!

We need to have a way of:

  • Signalling whether we have been using latin1 to save data (the current behaviour for ss)
  • Extract all text content using SET CHARACTER SET 'latin1'.
  • Save that content back using SET NAMES 'utf8'.
  • Telling the database that all the content has been saved as utf8, so we don't do this again in the future.

Perhaps we should add a DatabaseConfig? table or something, where we can store key-value pairs with information such as this? The other thing that DatabaseConfig? could be used for is storing the schema version of a database, if we were to improve our schema migration stuff.

Changed 4 months ago by ischommer

  • milestone changed from 2.2.3 to 2.3.0

Changed 3 months ago by sharvey

  • component changed from CMS - Field editor to CMS - General

Changed 3 months ago by sminnee

  • milestone changed from 2.3.0 to 2.4.0
Note: See TracTickets for help on using tickets.