From 8238cd0556df7052ef3e6fb5d20587e138e2633f Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 19 Sep 2013 12:40:03 -0300 Subject: [PATCH] Bug 10915: (Possible) QA followup - warn if cannot read history.txt This patch makes about.pl test if success opening history.txt, and shows a convenient warning to the end user. No more warnings in the logs (about.pl: readline() on closed filehandle $file at /usr/share/koha/intranet/cgi-bin/about.pl line 166) and better problem solving information for the end user. Regards To+ Sponsored-by: Universidad Nacional de Cordoba --- about.pl | 58 ++++++++++++---------- koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 6 +++ 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/about.pl b/about.pl index 0ba7291..6b44ea8 100755 --- a/about.pl +++ b/about.pl @@ -157,39 +157,43 @@ if ( defined C4::Context->config('docdir') ) { $docdir = C4::Context->config('intranetdir') . '/docs'; } -open( my $file, "<", "$docdir" . "/history.txt" ); -my $i = 0; +if ( open( my $file, "<", "$docdir" . "/history.txt" ) ) { -my @rows2 = (); -my $row2 = []; + my $i = 0; -my @lines = <$file>; -close($file); + my @rows2 = (); + my $row2 = []; -shift @lines; #remove header row + my @lines = <$file>; + close($file); -foreach (@lines) { - my ( $date, $desc, $tag ) = split(/\t/); - if(!$desc && $date=~ /(?<=\d{4})\s+/) { - ($date, $desc)= ($`, $'); - } - push( - @rows2, - { - date => $date, - desc => $desc, + shift @lines; #remove header row + + foreach (@lines) { + my ( $date, $desc, $tag ) = split(/\t/); + if(!$desc && $date=~ /(?<=\d{4})\s+/) { + ($date, $desc)= ($`, $'); } - ); -} + push( + @rows2, + { + date => $date, + desc => $desc, + } + ); + } -my $table2 = []; -#foreach my $row2 (@rows2) { -foreach (@rows2) { - push (@$row2, $_); - push( @$table2, { row2 => $row2 } ); - $row2 = []; -} + my $table2 = []; + #foreach my $row2 (@rows2) { + foreach (@rows2) { + push (@$row2, $_); + push( @$table2, { row2 => $row2 } ); + $row2 = []; + } -$template->param( table2 => $table2 ); + $template->param( table2 => $table2 ); +} else { + $template->param( timeline_read_error => 1 ); +} output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 5d32bbe..57aa522 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -530,6 +530,7 @@

Koha history timeline

+ [% IF ! timeline_read_error %] @@ -546,6 +547,11 @@ [% END %]
+ [% ELSE %] +
+ Could not read the history.txt file. Please make sure <docdir> is correctly defined in koha-conf.xml. +
+ [% END %]
-- 1.7.9.5