From ed67185035d190332a6feaf4828562f4d487ac5b 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 (cherry picked from commit 71574961f7322e04e996b11f9932b2006ea93215) Signed-off-by: Fridolin Somers --- 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 50952166f0..226d4f076d 100755 --- a/about.pl +++ b/about.pl @@ -200,6 +200,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 $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode(); my $warnIsRootUser = (! $loggedinuser); @@ -592,6 +596,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 328dc990cd..162230b808 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -207,7 +207,7 @@
- [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnPrefKohaAdminEmailAddress || 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 || 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.

@@ -291,7 +291,7 @@ Contact your system administrator. [% END %] - [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnPrefKohaAdminEmailAddress || 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 || 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

@@ -316,6 +316,9 @@ [% IF warnPrefKohaAdminEmailAddress %] [% END %] + [% IF warnPrefOpacHiddenItems %] + + [% END %] [% IF warnNoActiveCurrency %] [% END %] diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t index 980cd12bfe..611aa62721 100755 --- a/t/db_dependent/Koha/Items.t +++ b/t/db_dependent/Koha/Items.t @@ -1323,7 +1323,7 @@ $schema->storage->txn_rollback; subtest 'filter_by_visible_in_opac() tests' => sub { - plan tests => 11; + plan tests => 12; $schema->storage->txn_begin; @@ -1470,6 +1470,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 No active currency is defined. Please go to Administration > Currencies and exchange rates and mark one currency as active.