Bugzilla – Attachment 100695 Details for
Bug 24827
MARC preview fails when staged record contains items with UTF-8 characters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24827: Specify UTF-8 as encoding in new_from_xml()
Bug-24827-Specify-UTF-8-as-encoding-in-newfromxml.patch (text/plain), 5.22 KB, created by
Andreas Roussos
on 2020-03-15 07:49:43 UTC
(
hide
)
Description:
Bug 24827: Specify UTF-8 as encoding in new_from_xml()
Filename:
MIME Type:
Creator:
Andreas Roussos
Created:
2020-03-15 07:49:43 UTC
Size:
5.22 KB
patch
obsolete
>From 53aeda76c0434dd61d4c825b7d7ddf8602201c61 Mon Sep 17 00:00:00 2001 >From: Andreas Roussos <a.roussos@dataly.gr> >Date: Sun, 15 Mar 2020 08:43:25 +0100 >Subject: [PATCH] Bug 24827: Specify UTF-8 as encoding in new_from_xml() > >The MARC preview of staged records fails when a staged record contains >items with UTF-8 characters (see attached screenshots). That's because >in EmbedItemsInImportBiblio() the call to MARC::Record->new_from_xml() >does not explicitly specify 'UTF-8' as the optional encoding to use. > >This patch fixes that. > >Test plan (in a MARC21 instance): >0) Stage for import the test record attached to this bug report (make > sure that 'Check for embedded item record data?' is set to 'Yes'), > then go to Home > Tools > Manage staged MARC records and click on > the filename you've just staged. >1) In the 'Citation' column, click on the hyperlink to launch the MARC > preview -- notice how it fails to produce any output apart from the > modal heading. >2) Apply the patch, and restart Plack if necessary. >3) Re-launch the MARC preview: this time the output should include the > whole record, including the embedded item data in field 952. >4) Run the unit tests to ensure nothing was broken inadvertently: > $ prove t > $ prove xt >--- > C4/ImportBatch.pm | 2 +- > Koha/BiblioUtils/Iterator.pm | 2 +- > t/db_dependent/Koha/Z3950Responder/GenericSession.t | 8 ++++---- > t/db_dependent/Koha/Z3950Responder/ZebraSession.t | 4 ++-- > 4 files changed, 8 insertions(+), 8 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 11889fd3ee..eaf8b55c52 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -204,7 +204,7 @@ sub EmbedItemsInImportBiblio { > |, { Slice => {} }, $import_record_id ); > my @item_fields; > for my $import_item ( @$import_items ) { >- my $item_marc = MARC::Record::new_from_xml($import_item->{marcxml}); >+ my $item_marc = MARC::Record::new_from_xml($import_item->{marcxml}, 'UTF-8'); > push @item_fields, $item_marc->field($itemtag); > } > $record->append_fields(@item_fields); >diff --git a/Koha/BiblioUtils/Iterator.pm b/Koha/BiblioUtils/Iterator.pm >index 1c8c9d3d87..f8a4e41019 100644 >--- a/Koha/BiblioUtils/Iterator.pm >+++ b/Koha/BiblioUtils/Iterator.pm >@@ -95,7 +95,7 @@ sub next { > return if !$row; > my $marcxml = C4::Biblio::GetXmlBiblio( $row->get_column('biblionumber') ); > if ( $marcxml ) { >- $marc = MARC::Record->new_from_xml( $marcxml ); >+ $marc = MARC::Record->new_from_xml( $marcxml, 'UTF-8' ); > } > else { > confess "No marcxml column returned in the request."; >diff --git a/t/db_dependent/Koha/Z3950Responder/GenericSession.t b/t/db_dependent/Koha/Z3950Responder/GenericSession.t >index fd52dde5bc..f888b02121 100644 >--- a/t/db_dependent/Koha/Z3950Responder/GenericSession.t >+++ b/t/db_dependent/Koha/Z3950Responder/GenericSession.t >@@ -109,11 +109,11 @@ subtest 'test_search' => sub { > > is($rs->size(), 2, 'Two results returned'); > >- my $returned1 = MARC::Record->new_from_xml($rs->record(0)->raw()); >+ my $returned1 = MARC::Record->new_from_xml($rs->record(0)->raw(), 'UTF-8'); > ok($returned1, 'Record 1 returned as MARCXML'); > is($returned1->as_xml, $marc_record_1->as_xml, 'Record 1 returned properly'); > >- my $returned2= MARC::Record->new_from_xml($rs->record(1)->raw()); >+ my $returned2= MARC::Record->new_from_xml($rs->record(1)->raw(), 'UTF-8'); > ok($returned2, 'Record 2 returned as MARCXML'); > is($returned2->as_xml, $marc_record_2->as_xml, 'Record 2 returned properly'); > >@@ -140,11 +140,11 @@ subtest 'test_search' => sub { > my @records = $nodes[0]->getElementsByTagNameNS($marc_ns, 'record'); > is(scalar(@records), 2, 'Two results returned'); > >- $returned1 = MARC::Record->new_from_xml($records[0]->toString()); >+ $returned1 = MARC::Record->new_from_xml($records[0]->toString(), 'UTF-8'); > ok($returned1, 'Record 1 returned as MARCXML'); > is($returned1->as_xml, $marc_record_1->as_xml, 'Record 1 returned properly'); > >- $returned2= MARC::Record->new_from_xml($records[1]->toString()); >+ $returned2= MARC::Record->new_from_xml($records[1]->toString(), 'UTF-8'); > ok($returned2, 'Record 2 returned as MARCXML'); > is($returned2->as_xml, $marc_record_2->as_xml, 'Record 2 returned properly'); > >diff --git a/t/db_dependent/Koha/Z3950Responder/ZebraSession.t b/t/db_dependent/Koha/Z3950Responder/ZebraSession.t >index 4ba1a60571..3de0d2e838 100644 >--- a/t/db_dependent/Koha/Z3950Responder/ZebraSession.t >+++ b/t/db_dependent/Koha/Z3950Responder/ZebraSession.t >@@ -106,11 +106,11 @@ subtest 'test_search' => sub { > > is($rs->size(), 2, 'Two results returned'); > >- my $returned1 = MARC::Record->new_from_xml($rs->record(0)->raw()); >+ my $returned1 = MARC::Record->new_from_xml($rs->record(0)->raw(), 'UTF-8'); > ok ($returned1, 'Record 1 returned as MARCXML'); > is($returned1->as_xml, $marc_record_1->as_xml, 'Record 1 returned properly'); > >- my $returned2= MARC::Record->new_from_xml($rs->record(1)->raw()); >+ my $returned2= MARC::Record->new_from_xml($rs->record(1)->raw(), 'UTF-8'); > ok ($returned2, 'Record 2 returned as MARCXML'); > is($returned2->as_xml, $marc_record_2->as_xml, 'Record 2 returned properly'); > >-- >2.11.0
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 24827
:
100313
|
100314
|
100315
|
100320
|
100410
|
100694
|
100695
|
100737
|
100738
|
100739