Bugzilla – Attachment 51543 Details for
Bug 16505
rebuild_zebra.pl skips updates if -x is passed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 16505: <collection> is missing the marc namespace and updates fail if -x is passed
SIGNED-OFF-Bug-16505-collection-is-missing-the-mar.patch (text/plain), 5.60 KB, created by
Bernardo Gonzalez Kriegel
on 2016-05-16 16:06:32 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 16505: <collection> is missing the marc namespace and updates fail if -x is passed
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2016-05-16 16:06:32 UTC
Size:
5.60 KB
patch
obsolete
>From a7fe6ecf9c3cd707f743fdf0cffbf85a94d0b14c Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 13 May 2016 11:51:54 -0300 >Subject: [PATCH] [SIGNED-OFF] Bug 16505: <collection> is missing the marc > namespace and updates fail if -x is passed > >Using rebuild_zerba.pl with the -x option switch, produces an incorrect output in >terms of what our XSLTs expect for indexing. This patch introduces the right namespace information >on the exported records so indexing succeeds. > >To test: >- On current master, have some records on your db >- Run: > $ sudo koha-shell kohadev > $ cd kohaclone > $ misc/migration_tools/rebuild_zebra.pl -r -b -k -x >=> you will get a message like this: > >NOTHING cleaned : the export /tmp/NL5ufjUfpp has been kept. > >- Run > $ less /tmp/NL5ufjUfpp/biblio/exported_records >=> FAIL: The first line looks like this > ><?xml version="1.0" encoding="UTF-8"?><collection><record > >- Now run: > $ xsltproc \ > /etc/koha/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl \ > /tmp/NL5ufjUfpp/biblio/exported_records >=> FAIL: No output >- Apply the patch >- Run: > $ misc/migration_tools/rebuild_zebra.pl -r -b -k -x >- Take a look at the result file: > $ less /tmp/asdiouqwiue/biblio/exported_records >=> SUCCESS: The start of the file looks like this: ><?xml version="1.0" encoding="UTF-8"?><collection xmlns="http://www.loc.gov/MARC21/slim"> > >- Run: > $ xsltproc \ > /etc/koha/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl \ > /tmp/asdiouqwiue/biblio/exported_records >=> SUCCESS: There is actually indexing data :-D >- Sign off :-D > >Edit: I changed qq{} for q{} as suggested by Jonathan. > >Sponsored-by: American Numismatic Society > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Works as described following test plan >No errors >--- > misc/migration_tools/rebuild_zebra.pl | 45 +++++++++++++++++++++++------------ > 1 file changed, 30 insertions(+), 15 deletions(-) > >diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl >index beaf4d3..45c074a 100755 >--- a/misc/migration_tools/rebuild_zebra.pl >+++ b/misc/migration_tools/rebuild_zebra.pl >@@ -168,6 +168,14 @@ my $dbh = C4::Context->dbh; > my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField("biblio.biblionumber",""); > my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber",""); > >+my $marcxml_open = q{<?xml version="1.0" encoding="UTF-8"?> >+<collection xmlns="http://www.loc.gov/MARC21/slim"> >+}; >+ >+my $marcxml_close = q{ >+</collection> >+}; >+ > # Protect again simultaneous update of the zebra index by using a lock file. > # Create our own lock directory if its missing. This shouild be created > # by koha-zebra-ctl.sh or at system installation. If the desired directory >@@ -478,10 +486,10 @@ sub export_marc_records_from_sth { > > my $num_exported = 0; > open my $fh, '>:encoding(UTF-8) ', "$directory/exported_records" or die $!; >- if (include_xml_wrapper($as_xml, $record_type)) { >- # include XML declaration and root element >- print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>'; >- } >+ >+ print {$fh} $marcxml_open >+ if include_xml_wrapper($as_xml, $record_type); >+ > my $i = 0; > my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",''); > while (my ($record_number) = $sth->fetchrow_array) { >@@ -550,7 +558,8 @@ sub export_marc_records_from_sth { > } > } > print "\nRecords exported: $num_exported\n" if ( $verbose_logging ); >- print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type)); >+ print {$fh} $marcxml_close >+ if include_xml_wrapper($as_xml, $record_type); > close $fh; > return $num_exported; > } >@@ -560,10 +569,10 @@ sub export_marc_records_from_list { > > my $num_exported = 0; > open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!; >- if (include_xml_wrapper($as_xml, $record_type)) { >- # include XML declaration and root element >- print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>'; >- } >+ >+ print {$fh} $marcxml_open >+ if include_xml_wrapper($as_xml, $record_type); >+ > my $i = 0; > > # Skip any deleted records. We check for this anyway, but this reduces error spam >@@ -592,7 +601,10 @@ sub export_marc_records_from_list { > } > } > print "\nRecords exported: $num_exported\n" if ( $verbose_logging ); >- print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type)); >+ >+ print {$fh} $marcxml_close >+ if include_xml_wrapper($as_xml, $record_type); >+ > close $fh; > return $num_exported; > } >@@ -602,10 +614,10 @@ sub generate_deleted_marc_records { > > my $records_deleted = {}; > open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!; >- if (include_xml_wrapper($as_xml, $record_type)) { >- # include XML declaration and root element >- print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>'; >- } >+ >+ print {$fh} $marcxml_open >+ if include_xml_wrapper($as_xml, $record_type); >+ > my $i = 0; > foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) { > print "\r$i" unless ($i++ %100 or !$verbose_logging); >@@ -633,7 +645,10 @@ sub generate_deleted_marc_records { > $records_deleted->{$record_number} = 1; > } > print "\nRecords exported: $i\n" if ( $verbose_logging ); >- print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type)); >+ >+ print {$fh} $marcxml_close >+ if include_xml_wrapper($as_xml, $record_type); >+ > close $fh; > return $records_deleted; > >-- >1.9.1
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 16505
:
51476
|
51526
|
51543
|
51674
|
51679