Bug 8447: Make sure we have enough subfields for broader_headings
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Fri, 7 Sep 2012 14:58:53 +0000 (10:58 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 14 Sep 2012 12:56:48 +0000 (14:56 +0200)
Thanks to wajasu for providing the debugging information, as I cannot
seem to duplicate the problem, even seeing where it could come from.

Fix corrects cases where upon save, a software error complaing about
indicators being wrong as a side effect of a poorly autogenerated
biblio/authority record.

Behvior with this fix causes existing bilio data to to be preserved
while linking to the authority via subtag 9.

Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/Linker/Default.pm

index 653dabd..445b408 100644 (file)
@@ -56,17 +56,16 @@ sub get_link {
 
         if ( !defined $authid && $self->{'broader_headings'} ) {
             my $field     = $heading->field();
-            my @subfields = $field->subfields();
+            my @subfields = grep { $_->[0] ne '9' } $field->subfields();
             if ( scalar @subfields > 1 ) {
                 pop @subfields;
-                $field->replace_with(
+                $field =
                     MARC::Field->new(
                         $field->tag,
                         $field->indicator(1),
                         $field->indicator(2),
-                        map { $_[0] => $_[1] } @subfields
-                    )
-                );
+                        map { $_->[0] => $_->[1] } @subfields
+                    );
                 ( $authid, $fuzzy ) =
                   $self->get_link( C4::Heading->new_from_bib_field($field),
                     $behavior );