Browse Source

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 <gmc@esilibrary.com>
new/bootstrap-opac
Tomás Cohen Arazi 11 years ago
committed by Galen Charlton
parent
commit
45b85a700f
  1. 32
      about.pl
  2. 6
      koha-tmpl/intranet-tmpl/prog/en/modules/about.tt

32
about.pl

@ -157,18 +157,19 @@ 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) {
shift @lines; #remove header row
foreach (@lines) {
my ( $date, $desc, $tag ) = split(/\t/);
if(!$desc && $date=~ /(?<=\d{4})\s+/) {
($date, $desc)= ($`, $');
@ -180,16 +181,19 @@ foreach (@lines) {
desc => $desc,
}
);
}
}
my $table2 = [];
#foreach my $row2 (@rows2) {
foreach (@rows2) {
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;

6
koha-tmpl/intranet-tmpl/prog/en/modules/about.tt

@ -530,6 +530,7 @@
<div id="history">
<h2>Koha history timeline</h2>
[% IF ! timeline_read_error %]
<table style="cursor:pointer">
<thead>
<tr>
@ -546,6 +547,11 @@
</tr>
[% END %]
</table>
[% ELSE %]
<div class="dialog alert">
Could not read the history.txt file. Please make sure &lt;docdir&gt; is correctly defined in koha-conf.xml.
</div>
[% END %]
</div>
</div>

Loading…
Cancel
Save