[Bug 27161] New: Base.pm complains about unitialized value
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Bug ID: 27161 Summary: Base.pm complains about unitialized value Change sponsored?: --- Product: Koha Version: 19.11 Hardware: All OS: All Status: NEW Severity: trivial Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: cornejo.alvaro@gmail.com QA Contact: testopia@bugs.koha-community.org I get several errors on Use of uninitialized value in subroutine entry at /usr/share/koha/lib/Koha/Plugins/Base.pm line 182. 177 sub get_metadata { 178 my ( $self, $args ) = @_; 179 180 #FIXME: Why another encoding issue? For metadata containing non latin characters. 181 my $metadata = $self->{metadata}; 182 utf8::decode($metadata->{$_}) for keys %$metadata; 183 return $metadata; 184 } Verifying that $metadata value is set before applying utf8::decode will avoid that log error 177 sub get_metadata { 178 my ( $self, $args ) = @_; 179 180 #FIXME: Why another encoding issue? For metadata containing non latin characters. 181 my $metadata = $self->{metadata}; 182 if ($metadata !~ "") { 183 utf8::decode($metadata->{$_}) for keys %$metadata; 184 } 185 return $metadata; 186 } -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Alvaro Cornejo <cornejo.alvaro@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |cornejo.alvaro@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org --- Comment #1 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Could you submit a patch? -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 --- Comment #2 from Alvaro Cornejo <cornejo.alvaro@gmail.com> --- Created attachment 114295 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=114295&action=edit test patch Hope is OK. It does not fully avoid the "uninitialized value in subroutine" error but greatly reduces the number of errors. Patch against 19.11.11 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 --- Comment #3 from Alvaro Cornejo <cornejo.alvaro@gmail.com> --- Comment on attachment 114295 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=114295 test patch
--- Base.pm.orig 2020-12-09 22:11:25.639834095 -0500 +++ Base.pm 2020-12-07 19:41:17.903081236 -0500 @@ -179,7 +179,9 @@
#FIXME: Why another encoding issue? For metadata containing non latin characters. my $metadata = $self->{metadata}; + if ( $metadata & $metadata !~ "") { utf8::decode($metadata->{$_}) for keys %$metadata; + } return $metadata; }
-- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 --- Comment #4 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Hello Alvaro, you patch does not follow our guidelines (not git formatted). https://wiki.koha-community.org/wiki/Submitting_A_Patch Could you follow those steps? -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Alvaro Cornejo <cornejo.alvaro@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|koha-bugs@lists.koha-commun |cornejo.alvaro@gmail.com |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Alvaro Cornejo <cornejo.alvaro@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #114295|0 |1 is obsolete| | --- Comment #5 from Alvaro Cornejo <cornejo.alvaro@gmail.com> --- Created attachment 114360 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=114360&action=edit Base.pm patch to fix uninitialize variable error
From 32bfd2fe945e7aef6f489ddaf1c80be018622663 Mon Sep 17 00:00:00 2001 From: Alvaro Cornejo <cornejo.alvaro@gmail.com> Date: Fri, 11 Dec 2020 23:02:06 -0500 Subject: [PATCH] Bug 27161: Base.pm complains about unitialized value
This patch does validate that $metadata exists and is set in sub get_metadata TEST PLAN Before applying the patch tail plack error log and see errors like: Use of uninitialized value in subroutine entry at line 182 in Base.pm Apply the patch restart koha-common service tail plack error log and verify no more erros appear. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Alvaro Cornejo <cornejo.alvaro@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m --- Comment #6 from Fridolin Somers <fridolin.somers@biblibre.com> --- if ( $metadata & $metadata !~ "") second test is useless I think, if ($metadata) with skip undefined, empty string and 0 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 --- Comment #7 from Alvaro Cornejo <cornejo.alvaro@gmail.com> --- (In reply to Fridolin Somers from comment #6)
if ( $metadata & $metadata !~ "")
second test is useless I think, if ($metadata) with skip undefined, empty string and 0
Yes, I thought that but with only one of the tests there are still "undefined" variable errors. Not sure why, but with both tests error does not show anymore -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com --- Comment #8 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- I'm wondering if we ought to instead define a default.. i.e. my $metadata = $self->{metadata}; vs my $metadata = $self->{metadata} // {}; ? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com Status|Needs Signoff |In Discussion --- Comment #9 from David Nind <david@davidnind.com> --- Changed status to in discussion... feel free to change back when/if ready for sign off. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |25790 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25790 [Bug 25790] [OMNIBUS] warnings removal -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 --- Comment #10 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- In fact.. I'm not sure this makes sense at all.. a Plugin requires a metadata structure containing a version.. so even if we add `// {};` as a default, we would just be pushing the error elsewhere. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Status|In Discussion |RESOLVED --- Comment #11 from Fridolin Somers <fridolin.somers@biblibre.com> --- *** This bug has been marked as a duplicate of bug 28228 *** -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 --- Comment #12 from Fridolin Somers <fridolin.somers@biblibre.com> --- Alvaro Cornejo thanks a lot for your work, its continues on Bug 28228 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|25790 | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25790 [Bug 25790] [OMNIBUS] warnings removal -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27161 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |25790 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25790 [Bug 25790] [OMNIBUS] warnings removal -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org