r70119 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70118‎ | r70119 | r70120 >
Date:21:59, 28 July 2010
Author:nikerabbit
Status:ok (Comments)
Tags:
Comment:
Explicitly set mysql charsets to binary if not using utf-8 schema.

Apparently some distros are setting utf-8 as the default, which
would cause sql query errors if not using utf-8 schema.
Modified paths:
  • /trunk/phase3/includes/db/DatabaseMysql.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseMysql.php
@@ -112,6 +112,8 @@
113113 global $wgDBmysql5;
114114 if( $wgDBmysql5 ) {
115115 $this->query( 'SET NAMES utf8', __METHOD__ );
 116+ } else {
 117+ $this->query( 'SET NAMES binary', __METHOD__ );
116118 }
117119 // Set SQL mode, default is turning them all off, can be overridden or skipped with null
118120 global $wgSQLMode;

Comments

#Comment by Simetrical (talk | contribs)   22:11, 28 July 2010

Correctness of this is unclear. As Domas pointed out, people might be using something other than utf8 or binary.

#Comment by Nikerabbit (talk | contribs)   22:20, 28 July 2010

This work with latin1 & binary (actually tested with latin1), and I don't remember mediawiki offering any other options. I can't fix this if I don't know what is wrong.

Also, whatever solution we come up, it would be nice to have it in 1.16.

#Comment by Siebrand (talk | contribs)   11:13, 20 August 2010

Setting to new.

#Comment by Tim Starling (talk | contribs)   21:52, 7 February 2011

UTF-8 and binary are the only options. We used to have a latin1 option, which involved storing UTF-8 text in a latin1 field, a feat which could only work on MySQL 4.1+ if you're using binary as the client character set. I removed that option from the installer a while ago, since it breaks backups and is generally useless.

MediaWiki has not supported character sets other than UTF-8 for storage or display since 1.5.

Status & tagging log