From 71574961f7322e04e996b11f9932b2006ea93215 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 13 Apr 2021 10:47:19 +0200 Subject: [PATCH] Bug 28125: Display a warning on the about page for OPACHiddenItems is needed If OPACHiddenItems is containing badly construct it will lead to inconsistent behaviours. For instance the holds view will not display any items, when the detail page will display all of them (because we are not using the same code, we are in transition to merge it). This patch suggests to add a warning to the about page in case the query generated by Koha::Items->filter_by_visible_in_opac produces a warning Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Nick Clemens Bug 28125: (QA follow-up) Fix missing filter Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- about.pl | 5 +++++ koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 7 +++++-- t/db_dependent/Koha/Items.t | 8 +++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/about.pl b/about.pl index 376f77c6aa..90b434904c 100755 --- a/about.pl +++ b/about.pl @@ -201,6 +201,10 @@ my $warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist = ( not $anonymous_pat my $warnPrefKohaAdminEmailAddress = not Email::Valid->address(C4::Context->preference('KohaAdminEmailAddress')); +my $c = Koha::Items->filter_by_visible_in_opac->count; +my @warnings = C4::Context->dbh->selectrow_array('SHOW WARNINGS'); +my $warnPrefOpacHiddenItems = $warnings[2]; + my $invalid_yesno = Koha::Config::SysPrefs->search( { type => 'YesNo', @@ -601,6 +605,7 @@ $template->param( warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist => $warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist, warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist => $warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist, warnPrefKohaAdminEmailAddress => $warnPrefKohaAdminEmailAddress, + warnPrefOpacHiddenItems => $warnPrefOpacHiddenItems, errZebraConnection => $errZebraConnection, warnIsRootUser => $warnIsRootUser, warnNoActiveCurrency => $warnNoActiveCurrency, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index f589c65810..7ec5f4d7b5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -215,7 +215,7 @@
- [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnPrefKohaAdminEmailAddress || invalid_yesno.count || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships || log4perl_errors || config_bcrypt_settings_no_set || warnHiddenBiblionumbers.size || warnConnectBroker %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnPrefKohaAdminEmailAddress || warnPrefOpacHiddenItems || invalid_yesno.count || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships || log4perl_errors || config_bcrypt_settings_no_set || warnHiddenBiblionumbers.size || warnConnectBroker %] [% 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.

@@ -299,7 +299,7 @@ Contact your system administrator. [% END %] - [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnPrefKohaAdminEmailAddress || invalid_yesno.count || warnNoActiveCurrency || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules || config_bcrypt_settings_no_set || warnHiddenBiblionumbers.size || paypal_enabled %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnPrefKohaAdminEmailAddress || warnPrefOpacHiddenItems || invalid_yesno.count || warnNoActiveCurrency || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules || config_bcrypt_settings_no_set || warnHiddenBiblionumbers.size || paypal_enabled %]

Warnings regarding the system configuration

@@ -324,6 +324,9 @@ [% IF warnPrefKohaAdminEmailAddress %] [% END %] + [% IF warnPrefOpacHiddenItems %] + + [% END %] [% IF invalid_yesno.count %] [% FOR p IN invalid_yesno %] diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t index d1d910b020..73e1ab4a29 100755 --- a/t/db_dependent/Koha/Items.t +++ b/t/db_dependent/Koha/Items.t @@ -1494,7 +1494,7 @@ $schema->storage->txn_rollback; subtest 'filter_by_visible_in_opac() tests' => sub { - plan tests => 11; + plan tests => 12; $schema->storage->txn_begin; @@ -1641,6 +1641,12 @@ subtest 'filter_by_visible_in_opac() tests' => sub { 'The right item is returned' ); + # Make sure the warning on the about page will work + $rules = { itemlost => ['AB'] }; + my $c = Koha::Items->filter_by_visible_in_opac->count; + my @warnings = C4::Context->dbh->selectrow_array('SHOW WARNINGS'); + is( $warnings[2], q{Truncated incorrect DOUBLE value: 'AB'}); + $schema->storage->txn_rollback; }; -- 2.39.5
Preferences and parameters
Warning System preference 'KohaAdminEmailAddress' does not contain a valid email address. Emails will not be sent.
Warning System preference 'OpacHiddenItems' generates a warning and will produce unexpected behaviors: [% warnPrefOpacHiddenItems | html %]
Warning System preference '[% p.variable | html %]' must be '0' or '1', but is [% IF p.value.defined %]'[% p.value | html%]'[% ELSE %]NULL[% END %].