Commit 4edd1877 authored by David Maus's avatar David Maus
Browse files

Gracyfully fail on missing records

parent 83ea25f6
......@@ -24,13 +24,22 @@ function terminate (Request $request, Response $response) {
}
function load ($ident) {
$content = @file_get_contents(sprintf(PSI_TEMPLATE, $ident));
$context = stream_context_create(['http' => ['timeout' => 0.5]]);
$content = @file_get_contents(sprintf(PSI_TEMPLATE, $ident), false, $context);
if ($content) {
$content = normalizer_normalize($content);
} else {
$context = <<<CONTENT
<record xmlns="info:srw/schema/5/picaXML-v1.0">
<field tag="003@">
<subfield code="0">$ident</subfield>
</field>
</record>
CONTENT;
}
$reader = new PicaNormReader();
$reader->open($content);
return $reader->read();
}
}
function transform ($sourceUri, $templateUri) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment