Backport r16247 to avoid unwanted marc8_to_utf8 conversion of records with incorrect...
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 16 Apr 2010 14:34:30 +0000 (14:34 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 16 Apr 2010 14:34:30 +0000 (14:34 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_0@16249 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm

index f47b9cb..1279f37 100644 (file)
@@ -1656,7 +1656,7 @@ sub sru_search {
                        'open-ils.search.biblio.multiclass.query' => {offset => $offset, limit => $limit} => $search_string => 1
                )->gather(1);
 
-        my $bre = $supercat->request( 'open-ils.supercat.record.object.retrieve' => [ map { $_->[0] } @{$recs->{ids}} ] )->gather(1);
+               my $bre = $supercat->request( 'open-ils.supercat.record.object.retrieve' => [ map { $_->[0] } @{$recs->{ids}} ] )->gather(1);
 
                foreach my $record (@$bre) {
                        my $marcxml = $record->marc;
@@ -1667,6 +1667,13 @@ sub sru_search {
                                my $bib_holdings = $supercat->request('open-ils.supercat.record.basic_holdings.retrieve', $record->id, $shortname || '-')->gather(1);
                                my $marc = MARC::Record->new_from_xml($marcxml, 'UTF8', 'XML');
 
+                               # Force record leader to 'a' as our data is always UTF8
+                               # Avoids marc8_to_utf8 from being invoked with horrible results
+                               # on the off-chance the record leader isn't correct
+                               my $ldr = $marc->leader;
+                               substr($ldr, 9, 1, 'a');
+                               $marc->leader($ldr);
+
                                # Expects the record ID in the 001
                                $marc->delete_field($_) for ($marc->field('001'));
                                if (!$marc->field('001')) {
@@ -1714,9 +1721,9 @@ sub sru_search {
                        );
                }
 
-        $resp->numberOfRecords($recs->{count});
+               $resp->numberOfRecords($recs->{count});
 
-    } elsif ( $resp->type eq 'explain' ) {
+       } elsif ( $resp->type eq 'explain' ) {
                if (!$ex_doc) {
                        my $host = $cgi->virtual_host || $cgi->server_name;
 
@@ -1781,9 +1788,9 @@ sub sru_search {
                );
        }
 
-       print $cgi->header( -type => 'application/xml' );
-       print $U->entityize($resp->asXML) . "\n";
-    return Apache2::Const::OK;
+       print $cgi->header( -type => 'application/xml' );
+       print $U->entityize($resp->asXML) . "\n";
+       return Apache2::Const::OK;
 }