Bug 27673: Fix encoding issues - Dump
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 11 Feb 2021 09:52:44 +0000 (10:52 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 16 Feb 2021 13:54:50 +0000 (14:54 +0100)
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 <kyle@bywatersolutions.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
misc/migration_tools/bulkmarcimport.pl
misc/search_tools/export_elasticsearch_mappings.pl
reports/reserves_stats.pl

index 86040b6..2fcb968 100755 (executable)
@@ -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=>{}});
index a35882c..6e2b158 100755 (executable)
@@ -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) );
index 30ab062..b041b1b 100755 (executable)
@@ -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;