View | Details | Raw Unified | Return to bug 33270
Collapse All | Expand All

(-)a/Koha/OAI/Server/Repository.pm (-4 / +26 lines)
Lines 37-45 use YAML::XS; Link Here
37
use CGI qw/:standard -oldstyle_urls/;
37
use CGI qw/:standard -oldstyle_urls/;
38
use C4::Context;
38
use C4::Context;
39
use C4::Biblio qw( GetFrameworkCode );
39
use C4::Biblio qw( GetFrameworkCode );
40
use C4::Charset qw( StripNonXmlChars );
40
use Koha::XSLT::Base;
41
use Koha::XSLT::Base;
41
use Koha::Biblios;
42
use Koha::Biblios;
42
43
44
use MARC::Record;
45
43
=head1 NAME
46
=head1 NAME
44
47
45
Koha::OAI::Server::Repository - Handles OAI-PMH requests for a Koha database.
48
Koha::OAI::Server::Repository - Handles OAI-PMH requests for a Koha database.
Lines 178-185 sub get_biblio_marcxml { Link Here
178
    }
181
    }
179
182
180
    my $biblio = Koha::Biblios->find($biblionumber);
183
    my $biblio = Koha::Biblios->find($biblionumber);
181
    my $record = $biblio->metadata->record({ embed_items => $with_items, opac => 1 });
184
    my $record;
182
    if ( $expanded_avs ) {
185
    # Koha::Biblio::Metadata->record throws an exception on bad encoding,
186
    # we don't want OAI harvests to die, so we catch and warn, and try to clean the record
187
    eval { $record = $biblio->metadata->record({ embed_items => $with_items, opac => 1 }); };
188
    if ($@) {
189
        my $marcxml_error = $@;
190
        chomp $marcxml_error;
191
        warn $marcxml_error;
192
        eval {
193
            $record = MARC::Record->new_from_xml(
194
                StripNonXmlChars( $biblio->metadata->metadata ), 'UTF-8',
195
                $biblio->metadata->schema
196
            );
197
        };
198
        # If the record still cannot be built, we will warn and return undef
199
        # and record will be reported as deleted
200
        if( $@ ){
201
            $marcxml_error = $@;
202
            chomp $marcxml_error;
203
            warn $marcxml_error;
204
        }
205
    }
206
    if ( $record && $expanded_avs ) {
183
        my $frameworkcode = GetFrameworkCode($biblionumber) || '';
207
        my $frameworkcode = GetFrameworkCode($biblionumber) || '';
184
        my $record_processor = Koha::RecordProcessor->new(
208
        my $record_processor = Koha::RecordProcessor->new(
185
            {
209
            {
Lines 192-198 sub get_biblio_marcxml { Link Here
192
        );
216
        );
193
        $record_processor->process($record);
217
        $record_processor->process($record);
194
    }
218
    }
195
196
    return $record ? $record->as_xml_record() : undef;
219
    return $record ? $record->as_xml_record() : undef;
197
}
220
}
198
221
199
- 

Return to bug 33270