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 <black23@gmail.com>

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Josef Moravec 2018-10-05 13:43:54 +00:00 committed by Nick Clemens
parent d559f93151
commit 40f6822dc1
2 changed files with 32 additions and 2 deletions

View File

@ -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(

View File

@ -183,7 +183,7 @@
</div>
<div id="sysinfo">
[% 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) %]
<h2>Warning regarding current user</h2>
<p>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.</p>
@ -228,7 +228,7 @@
<br/>
[% 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 %]
<h2>Warnings regarding the system configuration</h2>
<table>
<caption>Preferences and parameters</caption>
@ -305,6 +305,11 @@
System preference 'RESTOAuth2ClientCredentials' is set, but the required Net::OAuth2::AuthorizationServer dependency is missing. The feature is disabled.
</td></tr>
[% END %]
[% IF bad_yaml_prefs %]
<tr><th scope="row"><b>Warning</b> </th><td>
Some YAML formatted system preferences have bad format: [% bad_yaml_prefs.join(', ') | html %]
</td></tr>
[% END %]
</table>
[% END %]
@ -376,6 +381,7 @@
[% END %]
</table>
[% END %]
[% ELSE %]
<p>No warnings.</p>
[% END %]