From 885758d109d54169c5fa0d9a8c738f634b2a406b Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 2 Oct 2015 10:17:09 -0400 Subject: [PATCH] LP 1502156: Fix marc_export error when dumping authorities. There is a chance that marc_export will attempt to call a nonexistent field on MARC::Record if an error occurs while exporting authority records. The bug could only be triggered if a conversion error occurred while exporting the authority as either MARCXML or USMARC. The fix is to rename a couple of variables in the Marque::Authority->next method to be more like those used in Marque::Biblio->next. This will have the side effect of making marc_export easier to maintain, since the variables used in one method will now have the same meaning as those in the other. Signed-off-by: Jason Stephenson Signed-off-by: Galen Charlton --- Open-ILS/src/support-scripts/marc_export.in | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Open-ILS/src/support-scripts/marc_export.in b/Open-ILS/src/support-scripts/marc_export.in index 348c4b3a6f..70a659f8e8 100755 --- a/Open-ILS/src/support-scripts/marc_export.in +++ b/Open-ILS/src/support-scripts/marc_export.in @@ -724,53 +724,53 @@ sub next { if ($data) { my $format = $Marque::config->option_value('format'); - my $are = $self->{fmClass}->from_bare_hash($data); + my $r = $self->{fmClass}->from_bare_hash($data); if ($format eq 'ARE') { - $output = OpenSRF::Utils::JSON->perl2JSON($are); + $output = OpenSRF::Utils::JSON->perl2JSON($r); } else { - my $r; + my $marc; eval { - $r = MARC::Record->new_from_xml($are->marc(), + $marc = MARC::Record->new_from_xml($r->marc(), $Marque::config->option_value('encoding'), $Marque::config->option_value('format')); }; if ($@) { - print STDERR "Error in authority record " . $are->id() . "\n"; + print STDERR "Error in authority record " . $r->id() . "\n"; print STDERR "$@\n"; import MARC::File::XML; # Reset SAX Parser. return $self->next(); } if ($Marque::config->option_value('replace_001')) { - my $tcn = $r->field('001'); + my $tcn = $marc->field('001'); if ($tcn) { - $tcn->update($are->id()); + $tcn->update($r->id()); } else { - $tcn = MARC::Field->new('001', $are->id()); - $r->insert_fields_ordered($tcn); + $tcn = MARC::Field->new('001', $r->id()); + $marc->insert_fields_ordered($tcn); } } if ($Marque::config->option_value('since')) { - my $leader = $r->leader(); - if ($U->is_true($are->deleted())) { + my $leader = $marc->leader(); + if ($U->is_true($r->deleted())) { substr($leader, 5, 1) = 'd'; - $r->leader($leader); + $marc->leader($leader); } else { my $create_date = Date::Manip::Date->new; - $create_date->parse($are->create_date()); + $create_date->parse($r->create_date()); my $edit_date = Date::Manip::Date->new; - $edit_date->parse($are->edit_date()); + $edit_date->parse($r->edit_date()); if ($self->{since_date}->cmp($create_date) < 0) { substr($leader, 5, 1) = 'n'; - $r->leader($leader); + $marc->leader($leader); } elsif ($self->{since_date}->cmp($edit_date) < 0) { substr($leader, 5, 1) = 'c'; - $r->leader($leader); + $marc->leader($leader); } } } if ($Marque::config->option_value('format') eq 'XML') { eval { - $output = $r->as_xml_record; + $output = $marc->as_xml_record; $output =~ s/^<\?.+?\?>$//mo; }; if ($@) { @@ -780,7 +780,7 @@ sub next { } } else { eval { - $output = $r->as_usmarc; + $output = $marc->as_usmarc; }; if ($@) { print STDERR "Error in authority record " . $r->id() . "\n"; -- 2.11.0