From 0d8c96452e215e4ff8d1f36fcbad1cc2274af5b7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 16 Apr 2020 17:16:59 +0200 Subject: [PATCH] Bug 25172: Identify and display possible problems on the about page --- about.pl | 20 +++++++++++++++++++ .../intranet-tmpl/prog/en/modules/about.tt | 15 +++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/about.pl b/about.pl index dc25550fd2..fc8dcec21c 100755 --- a/about.pl +++ b/about.pl @@ -25,6 +25,7 @@ use Modern::Perl; use CGI qw ( -utf8 ); use DateTime::TimeZone; use File::Spec; +use File::Slurp; use List::MoreUtils qw/ any /; use LWP::Simple; use Module::Load::Conditional qw(can_load); @@ -48,6 +49,7 @@ use Koha::Caches; use Koha::Config::SysPrefs; use Koha::Illrequest::Config; use Koha::SearchEngine::Elasticsearch; +use Koha::Logger; use C4::Members::Statistics; @@ -93,6 +95,24 @@ my $time_zone = { 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' }) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index d8f0dfa01b..d89910bac1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -184,7 +184,7 @@
- [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships || log4perl_errors %] [% IF (warnIsRootUser) %]

Warning regarding current user

You are logged in as the database administrative user. This is not recommended because some parts of Koha will not function as expected when using this account.

@@ -246,6 +246,19 @@ [% END %] [% END %] + [% IF log4perl_errors %] +

Logging system does not behave correctly

+ [% FOR e IN log4perl_errors %] + [% SWITCH e %] + [% CASE 'missing_config_entry' %]There is no 'log4perl_conf' entry in the config file. + [% CASE 'cannot_read_config_file' %]The log4perl config file cannot be opened. + [% CASE 'logfile_not_writable' %]One of the logfiles listed in the config file is not writable. + [% CASE 'cannot_init_module' %]The Koha::Logger module cannot be initiated correctly (check the log file). + [% CASE %]Unknown error "[% e %]" + [% END %] + [% END %] + [% END %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules %]

Warnings regarding the system configuration

-- 2.20.1