[Bug 12916] New: Use of uninitialized values $max and $min in C4/Tags.pm
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Bug ID: 12916 Summary: Use of uninitialized values $max and $min in C4/Tags.pm Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: trivial Priority: P5 - low Component: OPAC Assignee: oleonard@myacpl.org Reporter: veron@veron.ch QA Contact: testopia@bugs.koha-community.org If tag list is empty, sub stratify_tags issues a warning in opac-error.log because of uninitialized values $max and $min in C4/Tags.pm, line 600 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 --- Comment #1 from Marc Véron <veron@veron.ch> --- Created attachment 31792 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=31792&action=edit Bug 12916 - Use of uninitialized values $max and $min in C4/Tags.pm Test plan: Make sure that you have no tags In Opac, go to 'Tag cloud' Check opac-error.log for entries regarding uninitialized values $max and $min in C4/Tags.pm, line 600 Apply patch Reload page 'Tag cloud' Result: No more warnings in opac-error.log -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|oleonard@myacpl.org |veron@veron.ch QA Contact|testopia@bugs.koha-communit | |y.org | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 --- Comment #2 from Marc Véron <veron@veron.ch> --- Still applies on current master: 3.17.00.029 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #31792|0 |1 is obsolete| | --- Comment #3 from Owen Leonard <oleonard@myacpl.org> --- Created attachment 32590 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=32590&action=edit [SIGNED-OFF] Bug 12916 - Use of uninitialized values $max and $min in C4/Tags.pm Test plan: Make sure that you have no tags In Opac, go to 'Tag cloud' Check opac-error.log for entries regarding uninitialized values $max and $min in C4/Tags.pm, line 600 Apply patch Reload page 'Tag cloud' Result: No more warnings in opac-error.log Signed-off-by: Owen Leonard <oleonard@myacpl.org> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 --- Comment #4 from M. Tompsett <mtompset@hotmail.com> --- Comment on attachment 32590 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=32590 [SIGNED-OFF] Bug 12916 - Use of uninitialized values $max and $min in C4/Tags.pm Review of attachment 32590: --> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=12916&attachment=32590) ----------------------------------------------------------------- ::: C4/Tags.pm @@ +589,4 @@
sub stratify_tags { my ( $strata, $tags ) = @_;
+ my ( $min, $max ) = ( 0, 0 );
I'm not sure this is the correct solution. Look at 595. There is a !defined($min) check. The problem is there is nothing in the @$tags. By initializing to 0, if there are tags, and the minimum is 5, the minimum is never set correctly. Similarly, if there are tags, and the maximum is negative, the maximum is never set correctly. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 --- Comment #5 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 32604 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=32604&action=edit Bug 12916 - Missing Test to demonstrate warnings. Modifying C4/Tags.pm should have tests. TEST PLAN --------- 1) Apply this test patch only. 2) prove -v t/db_dependent/Tags.t -- should see two warnings. 3) Apply the first patch. 4) prove -v t/db_dependent/Tags.t -- no warnings. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Needs Signoff CC| |mtompset@hotmail.com --- Comment #6 from M. Tompsett <mtompset@hotmail.com> --- After further code reading and test, the proposed solution is adequate. Here are the missing tests to make testing trivial. :) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #32604|0 |1 is obsolete| | --- Comment #7 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 32605 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=32605&action=edit Bug 12916 - Missing Test to demonstrate warnings. Modifying C4/Tags.pm should have tests. TEST PLAN --------- 1) Apply this test patch only. 2) prove -v t/db_dependent/Tags.t -- should see two warnings. 3) Apply the first patch. 4) prove -v t/db_dependent/Tags.t -- no warnings. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #32605|0 |1 is obsolete| | --- Comment #8 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 32611 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=32611&action=edit Bug 12916 - Missing Test to demonstrate warnings. Modifying C4/Tags.pm should have tests. TEST PLAN --------- 1) Apply this test patch only. 2) prove -v t/db_dependent/Tags.t -- should see two warnings. 3) Apply the first patch. 4) prove -v t/db_dependent/Tags.t -- no warnings. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #9 from M. Tompsett <mtompset@hotmail.com> --- Sorry, prove -v t/db_dependent/Tags.t fails with signed off patch. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #32590|0 |1 is obsolete| | --- Comment #10 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 32612 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=32612&action=edit Bug 12916 - Use of uninitialized values $max and $min in C4/Tags.pm When the stratify_tags function is called without any tags, the $min and $max variables are left undefined, which triggers a warning message about uninitialized values in the subtraction. TEST PLAN --------- 1) prove -v t/db_dependent/Tags.t -- should succeed, but there is no test for empty tags. 2) Make sure that you have no tags 3) In Opac, go to 'Tag cloud' 4) Check the opac error log file (e.g. ~/koha-dev/var/log/koha-opac-error_log) for entries regarding uninitialized values $max and $min in C4/Tags.pm 5) apply this patch 6) prove -v t/db_dependent/Tags.t -- should still succeed, though no tests are added. 7) Reload page 'Tag cloud' -- Result: No additional warnings in opac error log file. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #32611|0 |1 is obsolete| | --- Comment #11 from Chris Cormack <chris@bigballofwax.co.nz> --- Created attachment 32700 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=32700&action=edit Bug 12916 - Missing Test to demonstrate warnings. Modifying C4/Tags.pm should have tests. TEST PLAN --------- 1) Apply this test patch only. 2) prove -v t/db_dependent/Tags.t -- should see two warnings. 3) Apply the first patch. 4) prove -v t/db_dependent/Tags.t -- no warnings. Signed-off-by: Chris <chris@bigballofwax.co.nz> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #32612|0 |1 is obsolete| | --- Comment #12 from Chris Cormack <chris@bigballofwax.co.nz> --- Created attachment 32701 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=32701&action=edit Bug 12916 - Use of uninitialized values $max and $min in C4/Tags.pm When the stratify_tags function is called without any tags, the $min and $max variables are left undefined, which triggers a warning message about uninitialized values in the subtraction. TEST PLAN --------- 1) prove -v t/db_dependent/Tags.t -- should succeed, but there is no test for empty tags. 2) Make sure that you have no tags 3) In Opac, go to 'Tag cloud' 4) Check the opac error log file (e.g. ~/koha-dev/var/log/koha-opac-error_log) for entries regarding uninitialized values $max and $min in C4/Tags.pm 5) apply this patch 6) prove -v t/db_dependent/Tags.t -- should still succeed, though no tests are added. 7) Reload page 'Tag cloud' -- Result: No additional warnings in opac error log file. Signed-off-by: Chris <chris@bigballofwax.co.nz> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #32700|0 |1 is obsolete| | Attachment #32701|0 |1 is obsolete| | --- Comment #13 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 32732 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=32732&action=edit [PASSED QA] Bug 12916 - Missing Test to demonstrate warnings. Modifying C4/Tags.pm should have tests. TEST PLAN --------- 1) Apply this test patch only. 2) prove -v t/db_dependent/Tags.t -- should see two warnings. 3) Apply the first patch. 4) prove -v t/db_dependent/Tags.t -- no warnings. Signed-off-by: Chris <chris@bigballofwax.co.nz> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 --- Comment #14 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 32733 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=32733&action=edit [PASSED QA] Bug 12916 - Use of uninitialized values $max and $min in C4/Tags.pm When the stratify_tags function is called without any tags, the $min and $max variables are left undefined, which triggers a warning message about uninitialized values in the subtraction. TEST PLAN --------- 1) prove -v t/db_dependent/Tags.t -- should succeed, but there is no test for empty tags. 2) Make sure that you have no tags 3) In Opac, go to 'Tag cloud' 4) Check the opac error log file (e.g. ~/koha-dev/var/log/koha-opac-error_log) for entries regarding uninitialized values $max and $min in C4/Tags.pm 5) apply this patch 6) prove -v t/db_dependent/Tags.t -- should still succeed, though no tests are added. 7) Reload page 'Tag cloud' -- Result: No additional warnings in opac error log file. Signed-off-by: Chris <chris@bigballofwax.co.nz> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> New and old tests pass. Works as described. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master CC| |tomascohen@gmail.com --- Comment #15 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Patches pushed to master. Thanks Marc and Mark! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 --- Comment #16 from M. Tompsett <mtompset@hotmail.com> --- Could this be included in 3.16.x? It applies cleanly. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12916 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version|master |3.16 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org