From 87df244cc2ebbe881174f3c753e5bc70bfb9b7c1 Mon Sep 17 00:00:00 2001 From: David Maus <maus@hab.de> Date: Wed, 22 May 2013 16:26:59 +0200 Subject: [PATCH] Throw BackendException on SRU XSLT processing error * VuFindSearch/Backend/SRU/Connector.php (process): Throw BackendException on XSLT processing error, don't check for XML prolog. --- .../src/VuFindSearch/Backend/SRU/Connector.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php index 85388683e6f..d02a497d677 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php @@ -261,18 +261,19 @@ class Connector implements LoggerAwareInterface * Process an SRU response. Returns either the raw XML string or a * SimpleXMLElement based on the contents of the class' raw property. * - * @param string $result SRU response + * @param string $response SRU response * * @return string|SimpleXMLElement */ - protected function process($result) + protected function process($response) { - if (substr($result, 0, 5) != '<?xml') { - throw new BackendException('Cannot Load Results'); - } - // Send back either the raw XML or a SimpleXML object, as requested: - $result = XSLTProcessor::process('sru-convert.xsl', $result); + $result = XSLTProcessor::process('sru-convert.xsl', $response); + if (!$result) { + throw new BackendException( + sprintf('Error processing SRU response: %20s', $response) + ); + } return $this->raw ? $result : simplexml_load_string($result); } } -- GitLab