Bugzilla – Attachment 85220 Details for
Bug 22323
Cronjob runreport.pl has a CSV encoding issue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22323: cronjob runreport.pl CSV add encoding
Bug-22323-cronjob-runreportpl-CSV-add-encoding.patch (text/plain), 2.54 KB, created by
Katrin Fischer
on 2019-02-17 11:22:57 UTC
(
hide
)
Description:
Bug 22323: cronjob runreport.pl CSV add encoding
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2019-02-17 11:22:57 UTC
Size:
2.54 KB
patch
obsolete
>From ab6f436bc795a3b8f4660b24c713a86769a5eb9a Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Wed, 13 Feb 2019 13:25:20 +0100 >Subject: [PATCH] Bug 22323: cronjob runreport.pl CSV add encoding >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Cronjob runreport.pl runs SQL reports and can export as CSV. >This export needs to be UTF-8 encoded. > >This pathes replaces use of Text::CSV_XS by Text::CSV::Encoded like in other places like tools/viewlog.pl. >It adds a decode of headers bcause they will be encoded lika other lines. > >Test plan: >1) Create a new item with itemnotes 'accentué' >2) Create a SQL report with : >SELECT barcode,itemnotes AS itè FROM items WHERE itemnotes LIKE 'accenté' >3) Run this report >4) You see well encoded header and content >5) Run from command line (replace X by report number) : >misc/cronjobs/runreport.pl X --format=csv --csv-header --store-results >6) You well encoded header and content >7) Go to saved reports table >8) Look at saved results of report >9) You well encoded header and content > >Signed-off-by: Mikaël Olangcay Brisebois <mikael.olangcay-brisebois@inLibro.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > misc/cronjobs/runreport.pl | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > >diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl >index 65cf7e44fb..c89a6d4844 100755 >--- a/misc/cronjobs/runreport.pl >+++ b/misc/cronjobs/runreport.pl >@@ -30,7 +30,7 @@ use Koha::DateUtils; > use Getopt::Long qw(:config auto_help auto_version); > use Pod::Usage; > use MIME::Lite; >-use Text::CSV_XS; >+use Text::CSV::Encoded; > use CGI qw ( -utf8 ); > use Carp; > use Encode; >@@ -273,17 +273,18 @@ foreach my $report_id (@ARGV) { > } > $message = $cgi->table(join "", @rows); > } elsif ($format eq 'csv') { >- my $csv = Text::CSV_XS->new({ >+ my $csv = Text::CSV::Encoded->new({ >+ encoding_out => 'utf8', > binary => 1, > quote_char => $quote, > sep_char => $separator, > }); > > if ( $csv_header ) { >- my $fields = $sth->{NAME}; >- $csv->combine( @$fields ); >+ my @fields = map { decode( 'utf8', $_ ) } @{ $sth->{NAME} }; >+ $csv->combine( @fields ); > $message .= $csv->string() . "\n"; >- push @rows_to_store, [@$fields] if $store_results; >+ push @rows_to_store, [@fields] if $store_results; > } > > while (my $line = $sth->fetchrow_arrayref) { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22323
:
85061
|
85189
| 85220