From b93ab6fea7ae08feadef92062ccc92b086e67c4f Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Fri, 5 Oct 2018 13:43:54 +0000 Subject: [PATCH] Bug 21502: Add check for YAML formatted system preferences to about page So far there are these yaml formatted preferences: UpdateNotForLoanStatusOnCheckin OpacHiddenItems BibtexExportAdditionalFields RisExportAdditionalFields UpdateItemWhenLostFromHoldList MarcFieldsToOrder MarcItemFieldsToOrder Test plan: 1) Add some badly formatted YAML into some of preferences listed above 2) Check the System information tab on About page for appropriate warnings Signed-off-by: Michal Denar Signed-off-by: Michal Denar --- about.pl | 24 ++++++++++++++++++++++++ koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 10 ++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/about.pl b/about.pl index 349dfc9668..f0becebac1 100755 --- a/about.pl +++ b/about.pl @@ -32,6 +32,7 @@ use XML::Simple; use Config; use Search::Elasticsearch; use Try::Tiny; +use YAML; use C4::Output; use C4::Auth; @@ -385,6 +386,29 @@ if ( C4::Context->preference('WebBasedSelfCheck') ); } +# Test YAML system preferences +# FIXME: This is list of current YAML formatted prefs, should by type of preference +my @yaml_prefs = ( + "UpdateNotForLoanStatusOnCheckin", + "OpacHiddenItems", + "BibtexExportAdditionalFields", + "RisExportAdditionalFields", + "UpdateItemWhenLostFromHoldList", + "MarcFieldsToOrder", + "MarcItemFieldsToOrder" +); +my @bad_yaml_prefs; +foreach my $syspref (@yaml_prefs) { + my $yaml = C4::Context->preference( $syspref ); + if ( $yaml ) { + eval { YAML::Load( "$yaml\n\n" ); }; + if ($@) { + push @bad_yaml_prefs, $syspref; + } + } +} +$template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs; + { my $dbh = C4::Context->dbh; my $patrons = $dbh->selectall_arrayref( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 2616a6efc3..36b33bce5b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -183,7 +183,7 @@
- [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs %] [% 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.

@@ -228,7 +228,7 @@
[% END %] - [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs %]

Warnings regarding the system configuration

@@ -305,6 +305,11 @@ System preference 'RESTOAuth2ClientCredentials' is set, but the required Net::OAuth2::AuthorizationServer dependency is missing. The feature is disabled. [% END %] + [% IF bad_yaml_prefs %] + + [% END %]
Preferences and parameters
Warning + Some YAML formatted system preferences have bad format: [% bad_yaml_prefs.join(', ') | html %] +
[% END %] @@ -376,6 +381,7 @@ [% END %] [% END %] + [% ELSE %]

No warnings.

[% END %] -- 2.11.0