From d774afe1214dd408d56430f70780353965cc07cc Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 19 Sep 2013 12:40:03 -0300 Subject: [PATCH] Bug 10915: (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. Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Galen Charlton (cherry picked from commit 45b85a700fcb4c9db07ec0bd13ecd8463696c4c2) Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 5b4ebc0435b57d0655c1c6be5c3951862bef16d1) Signed-off-by: Bernardo Gonzalez Kriegel (cherry picked from commit 5b4ebc0435b57d0655c1c6be5c3951862bef16d1) --- about.pl | 58 ++++++++++--------- .../intranet-tmpl/prog/en/modules/about.tt | 6 ++ 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/about.pl b/about.pl index 761f01a43e..f79e8d2117 100755 --- a/about.pl +++ b/about.pl @@ -154,39 +154,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 5c26841b2f..e51011d0c1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -489,6 +489,7 @@

Koha history timeline

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