From 77d197c361a71f7090add40651630a1d99b17058 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 19 Aug 2019 10:32:06 -0300 Subject: [PATCH] Bug 14570: Add about.pl entry for wrong relationship data This patch adds a check and an entry to the about.pl, for bad relationship data. The checks are: - 'relationship' containing '_bad_data' (generated by the atomicupdate on undef relationships. - 'relationship' values that are not in the borrowerRelationship syspref. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize --- about.pl | 46 +++++++++++++++++++ .../intranet-tmpl/prog/en/modules/about.tt | 19 +++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/about.pl b/about.pl index 4738c32ad0..31b30db170 100755 --- a/about.pl +++ b/about.pl @@ -460,6 +460,52 @@ $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs; ); } } + +# Guarantor relationships warnings +{ + my $dbh = C4::Context->dbh; + my ($bad_relationships_count) = $dbh->selectall_arrayref(q{ + SELECT COUNT(*) + FROM ( + SELECT relationship FROM borrower_relationships WHERE relationship='_bad_data' + UNION ALL + SELECT relationship FROM borrowers WHERE relationship='_bad_data') a + }); + + $bad_relationships_count = $bad_relationships_count->[0]->[0]; + + my @existing_relationships = $dbh->selectall_array(q{ + SELECT DISTINCT(relationship) + FROM ( + SELECT relationship FROM borrower_relationships WHERE relationship IS NOT NULL + UNION ALL + SELECT relationship FROM borrowers WHERE relationship IS NOT NULL) a + }); + + my %valid_relationships = map { $_ => 1 } split( /,|\|/, C4::Context->preference('borrowerRelationship') ); + $valid_relationships{ _bad_data } = 1; # we handle this case in another way + + my @wrong_relationships = grep { !$valid_relationships{ $_->[0] } } @existing_relationships; + + if ( @wrong_relationships or $bad_relationships_count ) { + + $template->param( + warnRelationships => 1, + ); + + if ( @wrong_relationships ) { + $template->param( + wrong_relationships => \@wrong_relationships + ); + } + if ($bad_relationships_count) { + $template->param( + bad_relationships_count => $bad_relationships_count, + ); + } + } +} + my %versions = C4::Context::get_versions(); $template->param( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 712dce775b..5b8c1c431e 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 || 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 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 || warnRelationships %] [% 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.

@@ -229,6 +229,23 @@
[% END %] + [% IF warnRelationships %] +

Patron relationship problems

+ [% IF bad_relationships_count %] +

Your database contained guarantee/guarantor pairs with no defined relationship. They have been set the value '_bad_data' in the [% "borrowers.relationship" | $HtmlTags tag="strong" %] and/or [% "borrower_relationships.relationship" | $HtmlTags tag="strong" %] columns. Fix them manually by recreating those relationships, or have your system's administrator correct the values.

+ [% END %] + + [% IF wrong_relationships %] +

The following values have been used for guarantee/guarantor relationships, but do not exist in the 'borrowerRelationship' system preference:

+
    + [% FOR rel IN wrong_relationships %] +
  • [% rel.0 | html %]
  • + [% END %] +
+

If the relationship is one you want, please add it to the 'borrowerRelationship' system preference, otherwise have your system's administrator correct the values in [% "borrowers.relationship" | $HtmlTags tag="strong" %] and/or [% "borrower_relationships.relationship" | $HtmlTags tag="strong" %] in the database.

+ [% END %] + [% END %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules %]

Warnings regarding the system configuration

-- 2.39.5