Bugzilla – Attachment 121039 Details for
Bug 28363
Always use semicolon when preference CSVDelimiter is missing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28363: Always use semicolon when preference CSVDelimiter is missing
Bug-28363-Always-use-semicolon-when-preference-CSV.patch (text/plain), 9.02 KB, created by
Fridolin Somers
on 2021-05-17 10:45:57 UTC
(
hide
)
Description:
Bug 28363: Always use semicolon when preference CSVDelimiter is missing
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2021-05-17 10:45:57 UTC
Size:
9.02 KB
patch
obsolete
>From de4b713c348d92fd27085d43fda0b68d6d3f3725 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Wed, 12 May 2021 15:34:15 +0200 >Subject: [PATCH] Bug 28363: Always use semicolon when preference CSVDelimiter > is missing > >Some places use comma as value when preference CSVDelimiter is missing or empty. >From installer/data/mysql/mandatory/sysprefs.sql whe see that default install value is semicolon. > >This patch sets semicolon when preference CSVDelimiter is missing. > >"We are perl, we love semicolon ;)" > >Test plan : >1) With SQL, set system preference 'CSVdelimiter' to empty string. >2) Create CSV export in impacted pages >3) Check columns are separated by semicolon character > >https://bugs.koha-community.org/show_bug.cgi?id=28327 >--- > Koha/Template/Plugin/Koha.pm | 2 +- > admin/aqplan.pl | 2 +- > .../prog/en/modules/admin/preferences/admin.pref | 2 +- > misc/cronjobs/fines.pl | 2 +- > misc/export_borrowers.pl | 4 ++-- > reports/bor_issues_top.pl | 2 +- > reports/cash_register_stats.pl | 2 +- > reports/guided_reports.pl | 2 +- > reports/orders_by_fund.pl | 2 +- > t/Koha_Template_Plugin_Koha.t | 8 ++++---- > tools/viewlog.pl | 2 +- > 11 files changed, 15 insertions(+), 15 deletions(-) > >diff --git a/Koha/Template/Plugin/Koha.pm b/Koha/Template/Plugin/Koha.pm >index caa47d33bb..f8373bf00b 100644 >--- a/Koha/Template/Plugin/Koha.pm >+++ b/Koha/Template/Plugin/Koha.pm >@@ -68,7 +68,7 @@ being fetched in the scripts and still needing to be translated > > sub CSVDelimiter { > my ( $self, $val ) = @_; >- my $sep = $val || C4::Context->preference('CSVDelimiter') || ','; >+ my $sep = $val || C4::Context->preference('CSVDelimiter') || ';'; > $sep = "\t" if $sep eq 'tabulation'; > return $sep; > } >diff --git a/admin/aqplan.pl b/admin/aqplan.pl >index 234892e697..bbf775c380 100755 >--- a/admin/aqplan.pl >+++ b/admin/aqplan.pl >@@ -303,7 +303,7 @@ foreach my $n (@names) { > # DEFAULT DISPLAY BEGINS > > my $CGIextChoice = ( 'CSV' ); # FIXME translation >-my $CGIsepChoice = ( C4::Context->preference("CSVDelimiter") ); >+my $CGIsepChoice = ( C4::Context->preference("CSVDelimiter") || ';' ); > > my ( @budget_lines, %cell_hash ); > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >index a858b1d0da..9623412918 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >@@ -44,7 +44,7 @@ Administration: > - > - "Default separator for columns in an exported CSV file: " > - pref: CSVDelimiter >- default: "," >+ default: ";" > choices: > ';': semicolons > tabulation: tabs >diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl >index afc6b4d556..4d5bebdb42 100755 >--- a/misc/cronjobs/fines.pl >+++ b/misc/cronjobs/fines.pl >@@ -99,7 +99,7 @@ my @other_fields = qw(days_overdue fine); > my $libname = C4::Context->preference('LibraryName'); > my $control = C4::Context->preference('CircControl'); > my $mode = C4::Context->preference('finesMode'); >-my $delim = "\t"; # ? C4::Context->preference('CSVDelimiter') || "\t"; >+my $delim = "\t"; # ? C4::Context->preference('CSVDelimiter') || ';'; > > my %is_holiday; > my $today = dt_from_string(); >diff --git a/misc/export_borrowers.pl b/misc/export_borrowers.pl >index 27292189e9..900fa4b97c 100755 >--- a/misc/export_borrowers.pl >+++ b/misc/export_borrowers.pl >@@ -49,7 +49,7 @@ $0 -h > Some characters like | or ; will need to be escaped > in the parameter setting, like -s=\\| or -s=\\; > If no separator is specified, the CSVDelimiter pref >- will be used (or a comma, if the pref is empty) >+ will be used (or a semicolon, if the pref is empty) > -H, --show-header Print field names on first row > -w, --where=CONDITION Condition to filter borrowers to export > (SQL where clause). >@@ -91,7 +91,7 @@ my $sth = $dbh->prepare($query); > $sth->execute; > > unless ( $separator ) { >- $separator = C4::Context->preference('CSVDelimiter') || ','; >+ $separator = C4::Context->preference('CSVDelimiter') || ';'; > $separator = "\t" if ($separator eq 'tabulation'); > } > >diff --git a/reports/bor_issues_top.pl b/reports/bor_issues_top.pl >index 265362bb0d..b768a17973 100755 >--- a/reports/bor_issues_top.pl >+++ b/reports/bor_issues_top.pl >@@ -61,7 +61,7 @@ my ($template, $borrowernumber, $cookie) > flagsrequired => {reports => '*'}, > debug => 1, > }); >-our $sep = $input->param("sep") || C4::Context->preference('CSVDelimiter') || ','; >+our $sep = $input->param("sep") || C4::Context->preference('CSVDelimiter') || ';'; > $sep = "\t" if ($sep eq 'tabulation'); > $template->param(do_it => $do_it, > ); >diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl >index be91bdceb1..b81d235db2 100755 >--- a/reports/cash_register_stats.pl >+++ b/reports/cash_register_stats.pl >@@ -157,7 +157,7 @@ if ($do_it) { > my $format = 'csv'; > my $reportname = $input->param('basename'); > my $reportfilename = $reportname ? "$reportname.$format" : "reportresults.$format" ; >- my $delimiter = C4::Context->preference('CSVDelimiter') || ','; >+ my $delimiter = C4::Context->preference('CSVDelimiter') || ';'; > $delimiter = "\t" if $delimiter eq 'tabulation'; > my @rows; > foreach my $row (@loopresult) { >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index 49dfc95a3e..1daf85356d 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -898,7 +898,7 @@ elsif ($phase eq 'Export'){ > $content .= join("\t", map { $_ // '' } @$row) . "\n"; > } > } else { >- my $delimiter = C4::Context->preference('CSVDelimiter') || ','; >+ my $delimiter = C4::Context->preference('CSVDelimiter') || ';'; > if ( $format eq 'csv' ) { > $delimiter = "\t" if $delimiter eq 'tabulation'; > $type = 'application/csv'; >diff --git a/reports/orders_by_fund.pl b/reports/orders_by_fund.pl >index 6ffe018c9a..5313cbbdd5 100755 >--- a/reports/orders_by_fund.pl >+++ b/reports/orders_by_fund.pl >@@ -209,7 +209,7 @@ else { > $template->param( budgetsloop => \@{$budgetloop}, > outputFormatloop => \@outputFormats, > delimiterloop => \@CSVdelimiters, >- delimiterPreference => C4::Context->preference('CSVDelimiter') >+ delimiterPreference => C4::Context->preference('CSVDelimiter') || ';' > ); > } > >diff --git a/t/Koha_Template_Plugin_Koha.t b/t/Koha_Template_Plugin_Koha.t >index 812f5f96cc..e7ab8cb625 100755 >--- a/t/Koha_Template_Plugin_Koha.t >+++ b/t/Koha_Template_Plugin_Koha.t >@@ -96,13 +96,13 @@ subtest "Koha::Template::Plugin::Koha::CSVDelimiter tests" => sub { > my $plugin = Koha::Template::Plugin::Koha->new(); > > t::lib::Mocks::mock_preference('CSVDelimiter', ''); >- is($plugin->CSVDelimiter(), ',', "CSVDelimiter() returns comma when preference is empty string"); >+ is($plugin->CSVDelimiter(), ';', "CSVDelimiter() returns semicolon when preference is empty string"); > > t::lib::Mocks::mock_preference('CSVDelimiter', undef); >- is($plugin->CSVDelimiter(), ',', "CSVDelimiter() returns comma when preference is undefined"); >+ is($plugin->CSVDelimiter(), ';', "CSVDelimiter() returns semicolon when preference is undefined"); > >- t::lib::Mocks::mock_preference('CSVDelimiter', ';'); >- is($plugin->CSVDelimiter(), ';', "CSVDelimiter() returns preference value when preference is not tabulation"); >+ t::lib::Mocks::mock_preference('CSVDelimiter', ','); >+ is($plugin->CSVDelimiter(), ',', "CSVDelimiter() returns preference value when preference is not tabulation"); > > t::lib::Mocks::mock_preference('CSVDelimiter', 'tabulation'); > is($plugin->CSVDelimiter(), "\t", "CSVDelimiter() returns \\t when preference is tabulation"); >diff --git a/tools/viewlog.pl b/tools/viewlog.pl >index d1ac92e396..22fc88e4ec 100755 >--- a/tools/viewlog.pl >+++ b/tools/viewlog.pl >@@ -227,7 +227,7 @@ if ($do_it) { > # Printing to a csv file > my $content = q{}; > if (@data) { >- my $delimiter = C4::Context->preference('CSVDelimiter') || ','; >+ my $delimiter = C4::Context->preference('CSVDelimiter') || ';'; > $delimiter = "\t" if $delimiter eq 'tabulation'; > my $csv = Text::CSV::Encoded->new( { encoding_out => 'utf8', sep_char => $delimiter } ); > $csv or die "Text::CSV::Encoded->new FAILED: " . Text::CSV::Encoded->error_diag(); >-- >2.30.2
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 28363
: 121039