View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000483 | Composr | commandr | public | 2012-05-12 23:51 | 2012-08-19 12:34 |
| Reporter | Chris Graham | Assigned To | Chris Graham | ||
| Severity | Feature-request | ||||
| Status | closed | Resolution | won't fix | ||
| Product Version | |||||
| Fixed in Version | |||||
| Summary | 0000483: New MySQL charset change command | ||||
| Description | Command to change everything about a character set. Takes charset param, defaults to utf-8. | ||||
| Additional Information | Outline... $charset='utf8'; header('Content-Type: text/plain'); $GLOBALS['NO_DB_SCOPE_CHECK']=true; $GLOBALS['SITE_DB']->query('ALTER DATABASE '.get_db_site().' DEFAULT CHARACTER SET '.filter_naughty($charset)); echo "Converted DB, sets default for new tables\n"; $tables=$GLOBALS['SITE_DB']->query_select('db_meta',array('DISTINCT m_table'),NULL,'ORDER BY m_table'); foreach ($tables as $table) { $GLOBALS['SITE_DB']->query('ALTER TABLE '.get_table_prefix().$table['m_table'].' CONVERT TO CHARACTER SET '.filter_naughty($charset)); echo 'Converted '.$table['m_table']."\n"; } $contents=file_get_contents(get_file_base().'/info.php'); if (strpos($contents,'$SITE_INFO[\'database_charset\']=')!==false) { $contents=preg_replace('#\$SITE_INFO\[\'database_charset\']=\'[\w\-]+\';','$SITE_INFO[\'database_charset\']=\''.filter_naughty($charset).'\';',$contents); file_put_contents($contents,$contents); echo 'Told info.php new charset\n"; } // TODO... Go through each lang pack, checking it is right charset, if not update Also ideally needs a parameter to force cleanup of literally-stored utf8 data in non-utf8 tables (does binary charset change). Document all this in the internationalisation tutorial. | ||||
| Tags | No tags attached. | ||||
| Time estimation (hours) | 2 | ||||
| Sponsorship open | |||||
|
|
"Also ideally needs a parameter to force cleanup of literally-stored utf8 data in non-utf8 tables (does binary charset change)." Since Composr now enforces the right communication character set, encoding problems are not buried but result in visible errors. Corruption cannot creep up, so this is not needed. |
|
|
I'd consider this functionality quite critical, except that most users will create their databases as utf-8 in the first place if they are using a non-anglicised host. That is fine, the default Western European used in Composr's EN pack works great with a utf-8 DB now. Plus people can do an export then re-import into a new DB, if they need to switch the DBs charset. So it's not an awful situation. I'd still love this Commandr command to exist. Probably next time I need to do a conversion I'll write the command and use it. |
|
|
As Composr is moving to utf-8, this will become irrelevant. |