Bug 32462

Summary: Warning in Koha::Item->columns_to_str
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: Architecture, internals, and plumbingAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: jonathan.druart
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32060
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 25790    

Description Fridolin Somers 2022-12-13 19:52:14 UTC
I see this warning :
[WARN] Use of uninitialized value in join or string at /home/koha/src/Koha/Item.pm line 1041.
I think it is in Koha::Item->columns_to_str() when more_subfields_xml contains an empty subfield :

<record>
  <leader>         a              </leader>
  <datafield tag="999" ind1=" " ind2=" ">
    <subfield code="q"></subfield>
  </datafield>
</record>
Comment 1 Jonathan Druart 2022-12-14 09:30:27 UTC
This change could work.

diff --git a/Koha/Item.pm b/Koha/Item.pm
index e508e7eb55c..f431f739b4f 100644
--- a/Koha/Item.pm
+++ b/Koha/Item.pm
@@ -1107,7 +1107,7 @@ sub columns_to_str {
         }
 
         while ( my ( $k, $v ) = each %$more_values ) {
-            $values->{$k} = join ' | ', @$v;
+            $values->{$k} = join ' | ', map { defined $_ ? $_ : q{} } @$v;
         }
     }