From a562101fdcdf5e276baff5b5c130979a3398cadf Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 11 Feb 2021 10:52:44 +0100 Subject: [PATCH] Bug 27673: Fix encoding issues - Dump MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Same as Load, but for Dump. Test plan: Edit ES mappings, replace withdrawn's label with "withdrawn ✔️ ❤️ ★" Export the mappings perl misc/search_tools/export_elasticsearch_mappings.pl > admin/searchengine/elasticsearch/mappings.yaml Reset mappings from the UI => Notice that the label is correct Signed-off-by: Kyle M Hall Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart --- misc/migration_tools/bulkmarcimport.pl | 5 +++-- misc/search_tools/export_elasticsearch_mappings.pl | 3 ++- reports/reserves_stats.pl | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index 86040b6dbe..2fcb968f71 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -16,6 +16,7 @@ use MARC::File::XML; use MARC::Record; use MARC::Batch; use MARC::Charset; +use Encode; use Koha::Script; use C4::Context; @@ -565,7 +566,7 @@ if ($logfile){ } if ($yamlfile) { open my $yamlfileout, q{>}, "$yamlfile" or die "cannot open $yamlfile \n"; - print $yamlfileout YAML::XS::Dump($yamlhash); + print $yamlfileout YAML::XS::Dump(Encode::decode_utf8($yamlhash)); } exit 0; @@ -633,7 +634,7 @@ sub get_heading_fields{ if ($authtypes){ $headingfields = YAML::XS::LoadFile($authtypes); $headingfields={C4::Context->preference('marcflavour')=>$headingfields}; - $debug && warn YAML::XS::Dump($headingfields); + $debug && warn YAML::XS::Dump(Encode::decode_utf8($headingfields)); } unless ($headingfields){ $headingfields=$dbh->selectall_hashref("SELECT auth_tag_to_report, authtypecode from auth_types",'auth_tag_to_report',{Slice=>{}}); diff --git a/misc/search_tools/export_elasticsearch_mappings.pl b/misc/search_tools/export_elasticsearch_mappings.pl index a35882cb4f..6e2b158a79 100755 --- a/misc/search_tools/export_elasticsearch_mappings.pl +++ b/misc/search_tools/export_elasticsearch_mappings.pl @@ -52,6 +52,7 @@ Full documentation. =cut use Modern::Perl; +use Encode; use Koha::Script; use Koha::Database; @@ -81,4 +82,4 @@ if ( $type && $type !~ /^(marc21|unimarc|normarc)$/ ) { my $mappings = Koha::SearchEngine::Elasticsearch::raw_elasticsearch_mappings( $type ); binmode STDOUT, ":encoding(UTF-8)"; -print YAML::XS::Dump($mappings); +print Encode::decode_utf8( YAML::XS::Dump($mappings) ); diff --git a/reports/reserves_stats.pl b/reports/reserves_stats.pl index 30ab0628d8..b041b1bf77 100755 --- a/reports/reserves_stats.pl +++ b/reports/reserves_stats.pl @@ -218,7 +218,6 @@ sub calculate { my @sqlorparams; my @sqlor; my @sqlwhere; - ($debug) and print STDERR YAML::XS::Dump($filters_hashref); foreach my $filter (keys %$filters_hashref){ my $string; my $stringfield=$filter; -- 2.39.5