Bug 11797 - auth_finder.pl: Odd number of elements in anonymous hash
Summary: auth_finder.pl: Odd number of elements in anonymous hash
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: MARC Authority data support (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Mark Tompsett
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-20 04:31 UTC by Mark Tompsett
Modified: 2015-06-04 23:30 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 11797 - auth_finder.pl: Odd number of elements in anonymous hash (1.44 KB, patch)
2014-02-20 04:45 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 11797 - Odd number of elements in hash (2.28 KB, patch)
2014-03-06 06:54 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 11797 - Odd number of elements in hash (2.33 KB, patch)
2014-03-06 07:12 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 11797 - Odd number of elements in hash (2.54 KB, patch)
2014-04-14 08:34 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 11797 - Odd number of elements in hash - UNIMARC (1.86 KB, patch)
2014-04-15 09:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 11797 - Odd number of elements in hash (2.56 KB, patch)
2014-04-15 15:03 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 11797 - Odd number of elements in hash - UNIMARC (1.86 KB, patch)
2014-04-15 15:03 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Tompsett 2014-02-20 04:31:43 UTC
While hunting through my live system Koha error logs I found:
auth_finder.pl: Odd number of elements in anonymous hash at /usr/share/koha/lib/C4/AuthoritiesMarc.pm line 1037.

So, I read the code and wondered what if a tag was missing in the giant if statement?

http://www.loc.gov/marc/authority/ad1xx3xx.html lists a 162, but there is no 162, nor is there an else on the giant if statement.

Test? I don't know, but the patch that follows should fix it.
Comment 1 Mark Tompsett 2014-02-20 04:45:46 UTC Comment hidden (obsolete)
Comment 2 Mark Tompsett 2014-03-06 06:54:16 UTC Comment hidden (obsolete)
Comment 3 Mark Tompsett 2014-03-06 07:12:53 UTC Comment hidden (obsolete)
Comment 4 Marcel de Rooy 2014-04-14 08:34:47 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2014-04-15 09:10:15 UTC Comment hidden (obsolete)
Comment 6 Galen Charlton 2014-04-15 14:58:32 UTC
Double-checking: was the MARC21 variant of this patch marked obsolete by mistake?
Comment 7 Jonathan Druart 2014-04-15 15:03:27 UTC
Created attachment 27133 [details] [review]
Bug 11797 - Odd number of elements in hash

This was discovered when someone triggered an authority search
on an authority record that was missing what is assumed the
default subfield for a given field.

It, however, also can be triggered in an OPAC authority search
by looking at the record that lacks the default subfield for a
given field.

TEST PLAN
---------
1) Create an authority record with 180$x and NOT 180$v.
   See C4::AuthoritiesMarc::BuildSummary in the 1.. foreach loop
   for known tags and default values. The default subfields are
   the first letter of the $subfields_to_report string.
2) Trigger the bug:
   Method 1: /cgi-bin/koha/opac-authoritiesdetail.pl?authid=#
             Where # is the authority id of your tweaked record.
             The error occurs in Normal view.
   Method 2: Home -> Cataloging -> + New record
                  -> Click the 'Tag Editor' on 100$a
                  Editing of $a to $b and back may be required.
3) Notice there is an error log entry.
4) Apply the patch
5) Attempt to trigger the bug again
6) That specific error log entry is not generated.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Could generate the warning with a missing 151$a with both methods.
No warning anymore after applying this patch.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 8 Jonathan Druart 2014-04-15 15:03:35 UTC
Created attachment 27134 [details] [review]
Bug 11797 - Odd number of elements in hash - UNIMARC

I got the same warning for my UNIMARC DB.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 9 Marcel de Rooy 2014-04-15 15:28:05 UTC
Can we reset the status of this report?
Comment 10 Mark Tompsett 2014-04-15 15:37:17 UTC
I agree it should be changed. I don't think Jonathan's patch has been signed off, hence the 'Needs Signoff' status.
Comment 11 Galen Charlton 2014-04-15 16:25:00 UTC
Pushed to master, along with a follow-up to normalize the two approaches taken to remove the warning and a patch that adds unit tests and regression tests.  Thanks, Mark and Jonathan!

Jonathan: I would be interested in seeing an example of a valid UNIMARC authority that triggers the bug.
Comment 12 Fridolin Somers 2014-08-06 09:19:41 UTC
Pushed to 3.14.x, will be in 3.14.10