From c40f8c923f48cc5261fd91891b50cde82191b673 Mon Sep 17 00:00:00 2001 From: tipaul Date: Wed, 4 Jan 2006 15:54:55 +0000 Subject: [PATCH] utf8 is a : go for beta test in HEAD. some explanations : - updater/updatedatabase => will transform all tables in innoDB (not related to utf8, just to warn you) AND collate them in utf8 / utf8_general_ci. The SQL command is : ALTER TABLE tablename DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci. - *-top.inc will show the pages in utf8 - THE HARD THING : for me, mysql-client and mysql-server were set up to communicate in iso8859-1, whatever the mysql collation ! Thus, pages were improperly shown, as datas were transmitted in iso8859-1 format ! After a full day of investigation, someone on usenet pointed "set NAMES 'utf8'" to explain that I wanted utf8. I could put this in my.cnf, but if I do that, ALL databases will "speak" in utf8, that's not what we want. Thus, I added a line in Context.pm : everytime a DB handle is opened, the communication is set to utf8. - using marcxml field and no more the iso2709 raw marc biblioitems.marc field. --- C4/Biblio.pm | 12 ++++++++-- C4/Context.pm | 6 ++++- .../default/en/includes/about-top.inc | 2 +- .../default/en/includes/acquisitions-top.inc | 2 +- .../default/en/includes/auth-search-top.inc | 2 +- .../default/en/includes/auth-top.inc | 2 +- .../default/en/includes/bull-top.inc | 2 +- .../default/en/includes/cat-top.inc | 2 +- .../default/en/includes/circulation-top.inc | 2 +- .../default/en/includes/error-top.inc | 2 +- .../default/en/includes/help-top.inc | 2 +- .../default/en/includes/marc-top.inc | 2 +- .../default/en/includes/members-top.inc | 2 +- .../default/en/includes/neutral-top.inc | 2 +- .../default/en/includes/opac-top.inc | 2 +- .../default/en/includes/parameters-top.inc | 2 +- .../default/en/includes/popup-top.inc | 2 +- .../default/en/includes/quicksearch-top.inc | 2 +- .../default/en/includes/reports-top.inc | 2 +- .../default/en/includes/reportswcal-top.inc | 2 +- updater/updatedatabase | 24 +++++++++++++++++++ 21 files changed, 57 insertions(+), 21 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index a3da03b64a..7f5c3a0b5a 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -277,10 +277,10 @@ sub MARCgetbiblio { # Returns MARC::Record of the biblio passed in parameter. my ( $dbh, $biblionumber ) = @_; - my $sth = $dbh->prepare('select marc from biblioitems where biblionumber=?'); + my $sth = $dbh->prepare('select marcxml from biblioitems where biblionumber=?'); $sth->execute($biblionumber); my ($marc) = $sth->fetchrow; - my $record = MARC::File::USMARC::decode($marc); + my $record = MARC::Record::new_from_xml($marc); return $record; } @@ -2884,6 +2884,14 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.134 2006/01/04 15:54:55 tipaul +# utf8 is a : go for beta test in HEAD. +# some explanations : +# - updater/updatedatabase => will transform all tables in innoDB (not related to utf8, just to warn you) AND collate them in utf8 / utf8_general_ci. The SQL command is : ALTER TABLE tablename DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci. +# - *-top.inc will show the pages in utf8 +# - THE HARD THING : for me, mysql-client and mysql-server were set up to communicate in iso8859-1, whatever the mysql collation ! Thus, pages were improperly shown, as datas were transmitted in iso8859-1 format ! After a full day of investigation, someone on usenet pointed "set NAMES 'utf8'" to explain that I wanted utf8. I could put this in my.cnf, but if I do that, ALL databases will "speak" in utf8, that's not what we want. Thus, I added a line in Context.pm : everytime a DB handle is opened, the communication is set to utf8. +# - using marcxml field and no more the iso2709 raw marc biblioitems.marc field. +# # Revision 1.133 2005/12/12 14:25:51 thd # # diff --git a/C4/Context.pm b/C4/Context.pm index f270d2655f..9c825613fa 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -408,8 +408,12 @@ sub _new_dbh my $db_host = $context->{"config"}{"hostname"}; my $db_user = $context->{"config"}{"user"}; my $db_passwd = $context->{"config"}{"pass"}; - return DBI->connect("DBI:$db_driver:$db_name:$db_host", + my $dbh= DBI->connect("DBI:$db_driver:$db_name:$db_host", $db_user, $db_passwd); + # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config. + # this is better than modifying my.cnf (and forcing all communications to be in utf8) + $dbh->do("set NAMES 'utf8'"); + return $dbh; } =item dbh diff --git a/koha-tmpl/intranet-tmpl/default/en/includes/about-top.inc b/koha-tmpl/intranet-tmpl/default/en/includes/about-top.inc index 5db9f8a449..77daa12e7b 100644 --- a/koha-tmpl/intranet-tmpl/default/en/includes/about-top.inc +++ b/koha-tmpl/intranet-tmpl/default/en/includes/about-top.inc @@ -4,7 +4,7 @@ KOHA: INTRANET: About /includes/common-style.css"> - + - + diff --git a/koha-tmpl/intranet-tmpl/default/en/includes/popup-top.inc b/koha-tmpl/intranet-tmpl/default/en/includes/popup-top.inc index c672e24cee..bf72fe2e89 100644 --- a/koha-tmpl/intranet-tmpl/default/en/includes/popup-top.inc +++ b/koha-tmpl/intranet-tmpl/default/en/includes/popup-top.inc @@ -3,7 +3,7 @@ popup - + /includes/common-style.css"> diff --git a/koha-tmpl/intranet-tmpl/default/en/includes/quicksearch-top.inc b/koha-tmpl/intranet-tmpl/default/en/includes/quicksearch-top.inc index b0cfb2a080..5b3ae8d361 100644 --- a/koha-tmpl/intranet-tmpl/default/en/includes/quicksearch-top.inc +++ b/koha-tmpl/intranet-tmpl/default/en/includes/quicksearch-top.inc @@ -3,7 +3,7 @@ popup - + /includes/common-style.css"> diff --git a/updater/updatedatabase b/updater/updatedatabase index c6e0fd92de..48c7d5ad3f 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -545,6 +545,22 @@ unless ($marcdone) { print "\rdone\n"; } +# MOVE all tables TO UTF-8 and innoDB +$sth = $dbh->prepare("show table status"); +$sth->execute; +while ( my $table = $sth->fetchrow_hashref ) { + if ($table->{Engine} ne 'InnoDB') { + $dbh->do("ALTER TABLE $table->{Name} TYPE = innodb"); + print "moving $table->{Name} to InnoDB\n"; + } + unless ($table->{Collation} =~ /^utf8/) { + $dbh->do("ALTER TABLE $table->{Name} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"); + # FIXME : maybe a ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 would be better, def char set seems to work fine. If any problem encountered, let's try with convert ! + print "moving $table->{Name} to utf8\n"; + } else { + } +} + # at last, remove useless fields foreach $table ( keys %uselessfields ) { my @fields = split /,/,$uselessfields{$table}; @@ -737,6 +753,14 @@ sub MARCgetitem { exit; # $Log$ +# Revision 1.125 2006/01/04 15:54:55 tipaul +# utf8 is a : go for beta test in HEAD. +# some explanations : +# - updater/updatedatabase => will transform all tables in innoDB (not related to utf8, just to warn you) AND collate them in utf8 / utf8_general_ci. The SQL command is : ALTER TABLE tablename DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci. +# - *-top.inc will show the pages in utf8 +# - THE HARD THING : for me, mysql-client and mysql-server were set up to communicate in iso8859-1, whatever the mysql collation ! Thus, pages were improperly shown, as datas were transmitted in iso8859-1 format ! After a full day of investigation, someone on usenet pointed "set NAMES 'utf8'" to explain that I wanted utf8. I could put this in my.cnf, but if I do that, ALL databases will "speak" in utf8, that's not what we want. Thus, I added a line in Context.pm : everytime a DB handle is opened, the communication is set to utf8. +# - using marcxml field and no more the iso2709 raw marc biblioitems.marc field. +# # Revision 1.124 2005/10/27 12:09:05 tipaul # new features for serial module : # - the last 5 issues are now shown, and their status can be changed (but not reverted to "waited", as there can be only one "waited") -- 2.39.5