[Koha-devel] patch for multiple subjects

Chris Michalak michalak at mech.ubc.ca
Tue Nov 18 00:48:07 CET 2003


There appears to be a bug in Koha 2.0.0pre4 (and pre5) when handling 
multiple subjects. The code is designed to handle multiple subjects per 
biblio (hence the use of an entirely seperate table) but there is a 
small bug in the code which prevents all but the last subject from being 
added to the bibliosubject table.

Well actually, to be more accurate all the subjects are added, but all 
but the last are subsequently deleted. Anyways, instead of going on and 
on about it, why don't I just give you the simple patch!

Thanks for all the hard work Koha developers.

*** Biblio.pm.bak       2003-11-17 21:45:33.000000000 -0800
--- Biblio.pm   2003-11-17 22:28:56.000000000 -0800
***************
*** 1261,1272 ****
         ($tagfield,$tagsubfield) = 
MARCfind_marc_from_kohafield($dbh,"bibliosubject.subject");
         my @subj = $record->field($tagfield);
         foreach my $subject (@subj) {
                 my @subjsubfield = $subject->subfield($tagsubfield);
-               my @subjects;
                 foreach my $subfieldcount (0..$#subjsubfield) {
                         push @subjects,$subjsubfield[$subfieldcount];
                 }
-               OLDmodsubject($dbh,$oldbibnum,1, at subjects);
         }
         # we must add bibnum and bibitemnum in MARC::Record...
         # we build the new field with biblionumber and biblioitemnumber
--- 1261,1272 ----
         ($tagfield,$tagsubfield) = 
MARCfind_marc_from_kohafield($dbh,"bibliosubject.subject");
         my @subj = $record->field($tagfield);
+       my @subjects;
         foreach my $subject (@subj) {
                 my @subjsubfield = $subject->subfield($tagsubfield);
                 foreach my $subfieldcount (0..$#subjsubfield) {
                         push @subjects,$subjsubfield[$subfieldcount];
                 }
         }
+       OLDmodsubject($dbh,$oldbibnum,1, at subjects);
         # we must add bibnum and bibitemnum in MARC::Record...
         # we build the new field with biblionumber and biblioitemnumber
***************
*** 1321,1332 ****
         ($tagfield,$tagsubfield) = 
MARCfind_marc_from_kohafield($dbh,"bibliosubject.subject");
         my @subj = $record->field($tagfield);
         foreach my $subject (@subj) {
                 my @subjsubfield = $subject->subfield($tagsubfield);
-               my @subjects;
                 foreach my $subfieldcount (0..$#subjsubfield) {
                         push @subjects,$subjsubfield[$subfieldcount];
                 }
-               OLDmodsubject($dbh,$oldbiblionumber,1, at subjects);
         }
         return 1;
   }
--- 1321,1332 ----
         ($tagfield,$tagsubfield) = 
MARCfind_marc_from_kohafield($dbh,"bibliosubject.subject");
         my @subj = $record->field($tagfield);
+       my @subjects;
         foreach my $subject (@subj) {
                 my @subjsubfield = $subject->subfield($tagsubfield);
                 foreach my $subfieldcount (0..$#subjsubfield) {
                         push @subjects,$subjsubfield[$subfieldcount];
                 }
         }
+       OLDmodsubject($dbh,$oldbiblionumber,1, at subjects);
         return 1;
   }






More information about the Koha-devel mailing list