From d7eba3d9530696d8a04a6eef9a59a6ad7b13826c Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Wed, 26 Jun 2013 20:45:46 +0200 Subject: [PATCH] Testing DBIx::Class, continued MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I tried to replace the GetBranchesLoop() call in C4/Auth.pm In my database, there is a branchname with a diacritic. Unfortunately, it's not properly handled: "Institut Protestant de Th�ologie" appears instead of "Institut Protestant de Théologie" If I force the page encoding to latin1, it appears correctly. Investigating DBIx::Class documentation, I find a Using Unicode chapter in DBIx::Class::Manual::Cookbook which says: MySQL supports unicode, and will correctly flag utf8 data from the database if the "mysql_enable_utf8" is set in the connect options. my $schema = My::Schema->connection('dbi:mysql:dbname=test', $user, $pass, { mysql_enable_utf8 => 1} ); When set, a data retrieved from a textual column type (char, varchar, etc) will have the UTF-8 flag turned on if necessary. This enables character semantics on that string. You will also need to ensure that your database / table / column is configured to use UTF8. See Chapter 10 of the mysql manual for details. See DBD::mysql for further details. This patch also adds the + mysql_enable_utf8 => 1, # REQUIRED to handle properly utf8 line, but unfortunately, it does not fix the problem. ideas welcomed... http://bugs.koha-community.org/show_bug.cgi?id=8798 --- C4/Auth.pm | 3 ++- Koha/Database.pm | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 3c0b804..befa487 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -984,8 +984,9 @@ sub checkauth { my $template_name = ( $type eq 'opac' ) ? 'opac-auth.tmpl' : 'auth.tmpl'; my $template = C4::Templates::gettemplate($template_name, $type, $query ); + my @branchloop= Koha::BusinessLogic::Branch->read()->all; $template->param( - branchloop => GetBranchesLoop(), + branchloop => \@branchloop, opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"), opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"), login => 1, diff --git a/Koha/Database.pm b/Koha/Database.pm index c10a61a..5fe6392 100644 --- a/Koha/Database.pm +++ b/Koha/Database.pm @@ -63,7 +63,10 @@ sub _new_schema { my $db_passwd = $context->config("pass"); my $schema = Koha::Schema->connect( "DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port", - $db_user, $db_passwd ); + $db_user, $db_passwd, + { + mysql_enable_utf8 => 1, # REQUIRED to handle properly utf8 + }); return $schema; } -- 1.7.9.5