Bugzilla – Attachment 28794 Details for
Bug 12409
The test t/db_dependent/Record.t fails with Perl 5.18.2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14391: Fix fields order on exporting to bibtex
Bug-14391-Fix-fields-order-on-exporting-to-bibtex.patch (text/plain), 4.83 KB, created by
Jonathan Druart
on 2014-06-12 09:11:03 UTC
(
hide
)
Description:
Bug 14391: Fix fields order on exporting to bibtex
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-06-12 09:11:03 UTC
Size:
4.83 KB
patch
obsolete
>From 46c89faeccfe632e0624dcc39dda36fb4a6f934e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 12 Jun 2014 11:06:58 +0200 >Subject: [PATCH] Bug 14391: Fix fields order on exporting to bibtex > >The C4::Record::marc2bibtex subroutine supposes hashref keys are sorted >which is wrong with perl 5.18 > >Note that the t/db_dependent/Record.t fails without this patch. > >Test plan (for perl >= 5.18 only): >1/ prove t/db_dependent/Record.t should return green >2/ Try to export a record to bibtex and verify the order is correct >(should be author, title, year, published, etc.). > >http://bugs.koha-community.org/show_bug.cgi?id=12409 >--- > C4/Record.pm | 89 ++++++++++++++++++++++++++++++++---------------------------- > 1 file changed, 47 insertions(+), 42 deletions(-) > >diff --git a/C4/Record.pm b/C4/Record.pm >index adb0c81..ba2fb39 100644 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -669,54 +669,59 @@ sub marc2bibtex { > $author = join ' and ', @texauthors; > > # Defining the conversion hash according to the marcflavour >- my %bh; >+ my @bh; > if ( $marcflavour eq "UNIMARC" ) { >- >- # FIXME, TODO : handle repeatable fields >- # TODO : handle more types of documents >- >- # Unimarc to bibtex hash >- %bh = ( >- >- # Mandatory >- author => $author, >- title => $record->subfield("200", "a") || "", >- editor => $record->subfield("210", "g") || "", >- publisher => $record->subfield("210", "c") || "", >- year => $record->subfield("210", "d") || $record->subfield("210", "h") || "", >- >- # Optional >- volume => $record->subfield("200", "v") || "", >- series => $record->subfield("225", "a") || "", >- address => $record->subfield("210", "a") || "", >- edition => $record->subfield("205", "a") || "", >- note => $record->subfield("300", "a") || "", >- url => $record->subfield("856", "u") || "" >- ); >+ >+ # FIXME, TODO : handle repeatable fields >+ # TODO : handle more types of documents >+ >+ # Unimarc to bibtex hash >+ @bh = ( >+ >+ # Mandatory >+ author => $author, >+ title => $record->subfield("200", "a") || "", >+ editor => $record->subfield("210", "g") || "", >+ publisher => $record->subfield("210", "c") || "", >+ year => $record->subfield("210", "d") || $record->subfield("210", "h") || "", >+ >+ # Optional >+ volume => $record->subfield("200", "v") || "", >+ series => $record->subfield("225", "a") || "", >+ address => $record->subfield("210", "a") || "", >+ edition => $record->subfield("205", "a") || "", >+ note => $record->subfield("300", "a") || "", >+ url => $record->subfield("856", "u") || "" >+ ); > } else { > >- # Marc21 to bibtex hash >- %bh = ( >- >- # Mandatory >- author => $author, >- title => $record->subfield("245", "a") || "", >- editor => $record->subfield("260", "f") || "", >- publisher => $record->subfield("264", "b") || $record->subfield("260", "b") || "", >- year => $record->subfield("264", "c") || $record->subfield("260", "c") || $record->subfield("260", "g") || "", >- >- # Optional >- # unimarc to marc21 specification says not to convert 200$v to marc21 >- series => $record->subfield("490", "a") || "", >- address => $record->subfield("264", "a") || $record->subfield("260", "a") || "", >- edition => $record->subfield("250", "a") || "", >- note => $record->subfield("500", "a") || "", >- url => $record->subfield("856", "u") || "" >- ); >+ # Marc21 to bibtex hash >+ @bh = ( >+ >+ # Mandatory >+ author => $author, >+ title => $record->subfield("245", "a") || "", >+ editor => $record->subfield("260", "f") || "", >+ publisher => $record->subfield("264", "b") || $record->subfield("260", "b") || "", >+ year => $record->subfield("264", "c") || $record->subfield("260", "c") || $record->subfield("260", "g") || "", >+ >+ # Optional >+ # unimarc to marc21 specification says not to convert 200$v to marc21 >+ series => $record->subfield("490", "a") || "", >+ address => $record->subfield("264", "a") || $record->subfield("260", "a") || "", >+ edition => $record->subfield("250", "a") || "", >+ note => $record->subfield("500", "a") || "", >+ url => $record->subfield("856", "u") || "" >+ ); > } > > $tex .= "\@book{"; >- $tex .= join(",\n", $id, map { $bh{$_} ? qq(\t$_ = {$bh{$_}}) : () } keys %bh); >+ my @elt; >+ for ( my $i = 0 ; $i < scalar( @bh ) ; $i = $i + 2 ) { >+ next unless $bh[$i+1]; >+ push @elt, qq|\t$bh[$i] = {$bh[$i+1]}|; >+ } >+ $tex .= join(",\n", $id, @elt); > $tex .= "\n}\n"; > > return $tex; >-- >2.0.0.rc2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12409
:
28794
|
28848
|
29529
|
29530