From 57e4e66eec30645ab664fdde54cda90a9dbc07ef Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 16 Sep 2021 12:15:57 +0000 Subject: [PATCH] Bug 29040: Quiet ninitialized value warnings in Languages.pm This patch makes a minor change to getTranslatedLanguages in Languages.pm in order to quiet a warning shown when the "interface" and "theme" variables are empty. To test, apply the patch go to Administration -> Item types -> Edit item type. - Check the error log: tail /var/log/koha/kohadev/plack-intranet-error.log - Before the patch you would see a warning, "Use of uninitialized value $interface in concatenation (.) or string at /kohadevbox/koha/C4/Languages.pm line 121." - After the patch there should be no new warnings. --- C4/Languages.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/C4/Languages.pm b/C4/Languages.pm index c05c31bf9e..376127d8b2 100644 --- a/C4/Languages.pm +++ b/C4/Languages.pm @@ -112,13 +112,16 @@ Returns a reference to an array of hashes: sub getTranslatedLanguages { my ($interface, $theme, $current_language, $which) = @_; my @languages; + my $cache_key = ""; my @enabled_languages = ( $interface && $interface eq 'intranet' ) ? split ",", C4::Context->preference('language') : split ",", C4::Context->preference('OPACLanguages'); my $cache = Koha::Caches->get_instance; - my $cache_key = "languages_${interface}_${theme}"; + if( defined $interface && defined $theme ){ + $cache_key = "languages_${interface}_${theme}"; + } if ($interface && $interface eq 'opac' ) { my $htdocs = C4::Context->config('opachtdocs'); my $cached = $cache->get_from_cache($cache_key); -- 2.20.1