Bug 39153: Move log4perl checks in about.pl

They were mostly under tab about, but they should be under sysinfo.

Test plan:
If you would move your log4perl file, plack.psgi crashes. So sorry
but we cannot test that.
Note that you cannot simulate logfile_not_writable either, since it
also crashes plack.psgi before reaching about.pl. See 39155.

So a trivial hack remains:
Bonus: Edit about.pl and changed the moved if( !-w $file ) test and
replace it by if ( 1 ) in the new sub log4perl_check.
Restart and verify that you now have an error message on sysinfo.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Marcel de Rooy 2025-02-18 14:03:39 +00:00 committed by Katrin Fischer
parent c80e9c015c
commit 9f9d5ddff8
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -120,23 +120,6 @@ if ( $tab eq 'about' ) {
environment_invalid => $env_invalid
};
{ # Logger checks
my $log4perl_config = C4::Context->config("log4perl_conf");
my @log4perl_errors;
if ( !$log4perl_config ) {
push @log4perl_errors, 'missing_config_entry';
} else {
my @lines = read_file($log4perl_config) or push @log4perl_errors, 'cannot_read_config_file';
for my $line (@lines) {
next unless $line =~ m|log4perl.appender.\w+.filename=(.*)|;
push @log4perl_errors, 'logfile_not_writable' unless -w $1;
}
}
eval { Koha::Logger->get };
push @log4perl_errors, 'cannot_init_module' and warn $@ if $@;
$template->param( log4perl_errors => @log4perl_errors );
}
$template->param(
time_zone => $time_zone,
current_date_and_time => output_pref( { dt => dt_from_string(), dateformat => 'iso' } )
@ -274,9 +257,7 @@ if ( $tab eq 'sysinfo' ) {
push @xml_config_warnings, { error => 'zebra_auth_index_mode_mismatch_warn' };
}
if ( !defined C4::Context->config('log4perl_conf') ) {
push @xml_config_warnings, { error => 'log4perl_entry_missing' };
}
log4perl_check( $template, \@xml_config_warnings );
if ( !defined C4::Context->config('lockdir') ) {
push @xml_config_warnings, { error => 'lockdir_entry_missing' };
@ -829,6 +810,34 @@ if ( $tab eq 'history' ) {
}
}
sub log4perl_check {
my ( $template, $xml_config_warnings ) = @_;
if ( !defined C4::Context->config('log4perl_conf') ) {
push @$xml_config_warnings, { error => 'log4perl_entry_missing' };
}
my $log4perl_config = C4::Context->config("log4perl_conf");
my @log4perl_errors;
if ( !$log4perl_config ) {
push @log4perl_errors, 'missing_config_entry';
} else {
my @lines = read_file($log4perl_config) or push @log4perl_errors, 'cannot_read_config_file';
for my $line (@lines) {
next unless $line =~ m|log4perl\.appender\.\w+\.filename=(.*)|;
my $file = $1;
if ( !-w $file ) {
push @log4perl_errors, 'logfile_not_writable';
#NOTE: An unwritable logfile blocks plack.psgi. So you won't reach this script. (BZ 39155)
}
}
}
eval { Koha::Logger->get };
push @log4perl_errors, 'cannot_init_module' and warn $@ if $@;
$template->param( log4perl_errors => @log4perl_errors );
}
sub elasticsearch_check {
my $template = shift;