Bug 29040 - Uninitialized value warning in Languages.pm
Summary: Uninitialized value warning in Languages.pm
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Jonathan Druart
QA Contact: Marcel de Rooy
URL:
Keywords:
: 28775 (view as bug list)
Depends on:
Blocks: 25790
  Show dependency treegraph
 
Reported: 2021-09-16 12:15 UTC by Owen Leonard
Modified: 2022-05-17 11:57 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This removes the cause of the warning message "Use of uninitialized value $interface in concatenation (.) or string at /kohadevbox/koha/C4/Languages.pm line 121." when editing item types.
Version(s) released in:
22.05.00,21.11.01,21.05.08


Attachments
Bug 29040: Quiet ninitialized value warnings in Languages.pm (1.72 KB, patch)
2021-09-16 12:48 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 29040: Quiet ninitialized value warnings in Languages.pm (1.77 KB, patch)
2021-09-16 19:43 UTC, David Nind
Details | Diff | Splinter Review
Bug 29040: Remove warning from the itemtype edit view (1.54 KB, patch)
2021-11-19 13:57 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29040: Remove warning from the itemtype edit view (1.58 KB, patch)
2021-12-05 17:23 UTC, David Nind
Details | Diff | Splinter Review
Bug 29040: Remove warning from the itemtype edit view (1.68 KB, patch)
2021-12-13 13:20 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2021-09-16 12:15:00 UTC
I noticed these warnings coming from getTranslatedLanguages when working on my OpacNav-to-news patch:

Use of uninitialized value $interface in concatenation (.) or string at /kohadevbox/koha/C4/Languages.pm line 121.
Use of uninitialized value $theme in concatenation (.) or string at /kohadevbox/koha/C4/Languages.pm line 121.
Comment 1 Owen Leonard 2021-09-16 12:48:17 UTC Comment hidden (obsolete)
Comment 2 David Nind 2021-09-16 19:43:49 UTC Comment hidden (obsolete)
Comment 3 Joonas Kylmälä 2021-09-18 08:42:11 UTC
The get_from_cache() function cannot be called without any value because it calls croak() if done so. This change will at least break the Koha installer, http://localhost:8081/cgi-bin/koha/installer/install.pl. Please also fix the typo in the commit title and check with perltidy your code follows the coding style: https://wiki.koha-community.org/wiki/Coding_Guidelines#PERL1:_Perltidy
Comment 4 Jonathan Druart 2021-11-19 13:57:25 UTC
Created attachment 127866 [details] [review]
Bug 29040: Remove warning from the itemtype edit view

Use of uninitialized value $interface in concatenation (.) or string at /kohadevbox/koha/C4/Languages.pm line 121.

We are expecting "intranet" or "opac", here we sent undef which raises a
warning.
For no change in behaviour we can send "both" (or whatever different
than "intranet" and "opac").

Test plan:
Hit /cgi-bin/koha/admin/itemtypes.pl?op=add_form&itemtype=BK
Notice that the warning does no longer appear in the logs with the patch
applied.
Comment 5 David Nind 2021-12-05 17:23:19 UTC
Created attachment 128253 [details] [review]
Bug 29040: Remove warning from the itemtype edit view

Use of uninitialized value $interface in concatenation (.) or string at /kohadevbox/koha/C4/Languages.pm line 121.

We are expecting "intranet" or "opac", here we sent undef which raises a
warning.
For no change in behaviour we can send "both" (or whatever different
than "intranet" and "opac").

Test plan:
Hit /cgi-bin/koha/admin/itemtypes.pl?op=add_form&itemtype=BK
Notice that the warning does no longer appear in the logs with the patch
applied.

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 Marcel de Rooy 2021-12-13 13:20:51 UTC
Created attachment 128459 [details] [review]
Bug 29040: Remove warning from the itemtype edit view

Use of uninitialized value $interface in concatenation (.) or string at /kohadevbox/koha/C4/Languages.pm line 121.

We are expecting "intranet" or "opac", here we sent undef which raises a
warning.
For no change in behaviour we can send "both" (or whatever different
than "intranet" and "opac").

Test plan:
Hit /cgi-bin/koha/admin/itemtypes.pl?op=add_form&itemtype=BK
Notice that the warning does no longer appear in the logs with the patch
applied.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 7 Fridolin Somers 2021-12-15 21:50:48 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 8 Marcel de Rooy 2021-12-16 09:19:21 UTC
*** Bug 28775 has been marked as a duplicate of this bug. ***
Comment 9 Marcel de Rooy 2021-12-16 09:22:33 UTC
I will still have a look at this call now on bug 29245.

my $translated_languages = C4::Languages::getTranslatedLanguages( "both", C4::Context->preference('template') );

When we ask for both, it is actually a bit weird to pass the staff theme too. But this is merely theoretical.
Comment 10 Marcel de Rooy 2021-12-16 10:00:16 UTC
Another question:

admin/localization.pl contains:
my $translated_languages = C4::Languages::getTranslatedLanguages( 'intranet', C4::Context->preference('template') );

Since we use both in itemtypes, I am wondering if this statement is wrong?
Comment 11 Kyle M Hall 2021-12-17 14:48:03 UTC
Pushed to 21.11.x for 21.11.01
Comment 12 Andrew Fuerste-Henry 2021-12-17 21:04:16 UTC
Pushed to 21.05.x for 21.05.08
Comment 13 Victor Grousset/tuxayo 2021-12-22 22:03:58 UTC
Not backported to oldoldstable (20.11.x). Feel free to ask if it's needed.