Bug 9274 - Software error in bibtex export
Summary: Software error in bibtex export
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: MARC Bibliographic data support (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Fridolin SOMERS
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks: 6201
  Show dependency treegraph
 
Reported: 2012-12-12 14:47 UTC by Fridolin SOMERS
Modified: 2014-05-26 21:04 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Proposed patch (1.89 KB, patch)
2012-12-12 14:51 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Proposed patch (commented) (2.61 KB, patch)
2013-01-03 10:14 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 9274: fix BibTex export to use GetMarcAuthors correctly (928 bytes, patch)
2013-01-16 18:24 UTC, Galen Charlton
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 9274: fix BibTex export to use GetMarcAuthors correctly (989 bytes, patch)
2013-01-18 09:46 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Proposed patch (revisited) (3.03 KB, patch)
2013-02-19 09:28 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 9274: Software error in bibtex export (3.22 KB, patch)
2013-02-21 20:38 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[PASSED QA] Bug 9274: Software error in bibtex export (3.39 KB, patch)
2013-03-30 21:26 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin SOMERS 2012-12-12 14:47:02 UTC
When trying to export a biblio or a basket in bibtext, you get a broken page :

"Software error:
Can't use string ("13057") as an ARRAY ref while "strict refs" in use at /home/koha/src/C4/Record.pm line 654.
Comment 1 Fridolin SOMERS 2012-12-12 14:51:58 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2012-12-26 15:41:49 UTC
(In reply to comment #1)
> Problem comes from the call at C4::Biblio::GetMarcAuthors.

Hi Fridolyn,
Could you explain more precisely the reason why please?
Your patch duplicates some information (mintag and maxtag are already defined in GetMarcAuthors).
Comment 3 Owen Leonard 2012-12-27 16:15:24 UTC
Please also resubmit your patch with a commit message which describes the problem, describes the solution, and provides a test plan.
Comment 4 Fridolin SOMERS 2013-01-03 10:14:06 UTC Comment hidden (obsolete)
Comment 5 Fridolin SOMERS 2013-01-03 10:15:36 UTC
Has explained in patch comment :

Exporting to Bibtex from OPAC returns a software error.
This is because call to C4::Biblio::GetMarcAuthors does not return only authors but also authority link.
This patch replaces this call by a direct read of MARC::Record, like for other Bibtex datas.
C4::Biblio::GetMarcAuthors is really destinated to a direct use in a template.
Also, actually all author subfields are joined with 'and'. According to Bibtext format, authors sould be : <first name> <last name> and ...

Feel free to ask more details.
Comment 6 Galen Charlton 2013-01-16 18:23:42 UTC
I'm a little hesitant about the code duplication, but I agree that GetMarcAuthors isn't suitable (even with the crash put aside).

However, the way that names are constructed isn't quite right for MARC21, as the 700$b is *not* the first name, it's numeration associated with the name (e.g., John Doe III), and consequently should not precede the contents of $a.
Comment 7 Galen Charlton 2013-01-16 18:24:18 UTC Comment hidden (obsolete)
Comment 8 Galen Charlton 2013-01-16 18:25:34 UTC
I've attached a counter-patch that simply avoids the crash without changing behavior.

If we decide to change how MARC is translated to BibTex, we may as well work on bug 6201 as well.
Comment 9 Fridolin SOMERS 2013-01-18 09:43:20 UTC
I agree with your patch and will sign it.
Comment 10 Fridolin SOMERS 2013-01-18 09:46:08 UTC Comment hidden (obsolete)
Comment 11 Marcel de Rooy 2013-02-01 11:02:31 UTC
The patches fixes the problem with several authors. So, no crash. That is great! 
But if the marc fields include more information than the name in $a, they are attached as well in the string.
For instance a 700$a with a name and a 700$4 with a relator code sht (supporting host?), make this as author name (marc21):
author = "Bohlmann, Carolin and Museumslandschaft Hessen Kassel and Museum Schloss Wilhelmshöhe and sht"

The part "and sht" comes from the $4 and should not be included. The results from GetMarcAuthors need one more level of "grepping" on code equals $a. In my view this report could address that now too. 

I do not feel that this report should also address the "who is an author" discussion here. But note that not everybody in 7XX will be an author. In my testcase above Carolin is author, the second 700 is editor and the third is the host for the exhibition (the book is the exhibition catalog). But as said, we leave the scope of this report now.

Note that this patch is marked trivial (one line), but reading multiple maps and greps on one line is certainly not that trivial :)

Could you please send a correction or followup?

Failed QA
Comment 12 Fridolin SOMERS 2013-02-01 15:15:59 UTC
(In reply to comment #11)
> The patches fixes the problem with several authors. So, no crash. That is
> great! 
> But if the marc fields include more information than the name in $a, they
> are attached as well in the string.
That is why I didn't use C4::Biblio::GetMarcAuthors in my first patch (attachment 14387 [details] [review]).
Maybe someone can use it to add MARC21 specific cases ?
Comment 13 Fridolin SOMERS 2013-02-19 09:28:47 UTC Comment hidden (obsolete)
Comment 14 Bernardo Gonzalez Kriegel 2013-02-21 20:38:12 UTC Comment hidden (obsolete)
Comment 15 Owen Leonard 2013-03-26 22:49:42 UTC
I just ran across this issue when testing Bug 6201. This patch resolved the problem.
Comment 16 Katrin Fischer 2013-03-30 21:26:41 UTC
Created attachment 17059 [details] [review]
[PASSED QA] Bug 9274: Software error in bibtex export

Exporting to Bibtex from OPAC returns a software error.
This is because call to C4::Biblio::GetMarcAuthors does
not return only authors but also authority link.
This patch replaces this call by a direct read of
MARC::Record, like for other Bibtex datas.
C4::Biblio::GetMarcAuthors is really destinated to a
direct use in a template.
Also, actually all author subfields are joined with
'and'. According to Bibtext format, authors should be
"firstname surname and ..." or "surname, firstname and
...". I have choosen second one because in non-UNIMARC
it corresponds to $a content.

For example UNIMARC :
700 $aDoe $bJohn
700 $aDoe $bJanne
Gives : Doe, John and Doe, Janne
For example MARC21 :
700 $aDoe, John
700 $aDoe, Janne
Gives : Doe, John and Doe, Janne

Test plan :
Without patch :
Exporting to Bibtex from OPAC returns a software error.
With patch :
Exporting to Bibtex from OPAC succeeds.
Authors are composed using : $a, $b and ... for UNIMARC, $a ... for other marc flavours.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Comment: Works as decribed. All record export that produces
error pre-patch, now export without error.
No koha-qa errors

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Fixes error and output of additional authors.
Main entry in 100 is still missing.
All tests and  QA script pass.
Comment 17 Jared Camins-Esakov 2013-03-31 01:00:18 UTC
This patch has been pushed to master.
Comment 18 Chris Cormack 2013-03-31 05:54:14 UTC
Pushed to 3.10.x and 3.8.x will be in 3.10.5 and 3.8.12