VuFindSearch \ Backend \ Exception \ BackendException
Problem connecting to Solr.
Previous exceptions
  • Unable to connect to localhost:8081 . Error #0: stream_socket_client(): unable to connect to localhost:8081 (Connection refused) (0)
  • stream_socket_client(): unable to connect to localhost:8081 (Connection refused) (0)
VuFindSearch\Backend\Exception\BackendException thrown with message "Problem connecting to Solr." Stacktrace: #24 VuFindSearch\Backend\Exception\BackendException in /usr/local/vufind/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Connector.php:398 #23 VuFindSearch\Backend\Solr\Connector:forceToBackendException in /usr/local/vufind/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Connector.php:437 #22 Zend\Http\Client\Adapter\Exception\RuntimeException in /usr/local/vufind/vendor/zendframework/zend-http/src/Client/Adapter/Socket.php:286 #21 ErrorException in /usr/local/vufind/vendor/zendframework/zend-http/src/Client/Adapter/Socket.php:275 #20 stream_socket_client in /usr/local/vufind/vendor/zendframework/zend-http/src/Client/Adapter/Socket.php:275 #19 Zend\Http\Client\Adapter\Socket:connect in /usr/local/vufind/vendor/zendframework/zend-http/src/Client.php:1440 #18 Zend\Http\Client:doRequest in /usr/local/vufind/vendor/zendframework/zend-http/src/Client.php:940 #17 Zend\Http\Client:send in /usr/local/vufind/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Connector.php:457 #16 VuFindSearch\Backend\Solr\Connector:send in /usr/local/vufind/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Connector.php:426 #15 VuFindSearch\Backend\Solr\Connector:trySolrUrls in /usr/local/vufind/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Connector.php:365 #14 VuFindSearch\Backend\Solr\Connector:query in /usr/local/vufind/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Connector.php:186 #13 VuFindSearch\Backend\Solr\Connector:retrieve in /usr/local/vufind/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php:157 #12 VuFindSearch\Backend\Solr\Backend:retrieve in /usr/local/vufind/module/VuFindSearch/src/VuFindSearch/Service.php:140 #11 VuFindSearch\Service:retrieve in /usr/local/vufind/module/VuFind/src/VuFind/Record/Loader.php:119 #10 VuFind\Record\Loader:load in /usr/local/vufind/module/VuFind/src/VuFind/Controller/AbstractRecord.php:617 #9 VuFind\Controller\AbstractRecord:loadRecord in /usr/local/vufind/module/VuFind/src/VuFind/Controller/AbstractRecord.php:525 #8 VuFind\Controller\AbstractRecord:exportAction in /usr/local/vufind/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php:78 #7 Zend\Mvc\Controller\AbstractActionController:onDispatch in /usr/local/vufind/vendor/zendframework/zend-eventmanager/src/EventManager.php:322 #6 Zend\EventManager\EventManager:triggerListeners in /usr/local/vufind/vendor/zendframework/zend-eventmanager/src/EventManager.php:179 #5 Zend\EventManager\EventManager:triggerEventUntil in /usr/local/vufind/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php:104 #4 Zend\Mvc\Controller\AbstractController:dispatch in /usr/local/vufind/vendor/zendframework/zend-mvc/src/DispatchListener.php:138 #3 Zend\Mvc\DispatchListener:onDispatch in /usr/local/vufind/vendor/zendframework/zend-eventmanager/src/EventManager.php:322 #2 Zend\EventManager\EventManager:triggerListeners in /usr/local/vufind/vendor/zendframework/zend-eventmanager/src/EventManager.php:179 #1 Zend\EventManager\EventManager:triggerEventUntil in /usr/local/vufind/vendor/zendframework/zend-mvc/src/Application.php:332 #0 Zend\Mvc\Application:run in /usr/local/vufind/public/index.php:71
Stack frames (25)
24
VuFindSearch
\
Backend
\
Exception
\
BackendException
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
398
23
VuFindSearch
\
Backend
\
Solr
\
Connector
forceToBackendException
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
437
22
Zend
\
Http
\
Client
\
Adapter
\
Exception
\
RuntimeException
/
vendor
/
zendframework
/
zend-http
/
src
/
Client
/
Adapter
/
Socket.php
286
21
ErrorException
/
vendor
/
zendframework
/
zend-http
/
src
/
Client
/
Adapter
/
Socket.php
275
20
stream_socket_client
/
vendor
/
zendframework
/
zend-http
/
src
/
Client
/
Adapter
/
Socket.php
275
19
Zend
\
Http
\
Client
\
Adapter
\
Socket
connect
/
vendor
/
zendframework
/
zend-http
/
src
/
Client.php
1440
18
Zend
\
Http
\
Client
doRequest
/
vendor
/
zendframework
/
zend-http
/
src
/
Client.php
940
17
Zend
\
Http
\
Client
send
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
457
16
VuFindSearch
\
Backend
\
Solr
\
Connector
send
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
426
15
VuFindSearch
\
Backend
\
Solr
\
Connector
trySolrUrls
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
365
14
VuFindSearch
\
Backend
\
Solr
\
Connector
query
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
186
13
VuFindSearch
\
Backend
\
Solr
\
Connector
retrieve
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Backend.php
157
12
VuFindSearch
\
Backend
\
Solr
\
Backend
retrieve
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Service.php
140
11
VuFindSearch
\
Service
retrieve
/
module
/
VuFind
/
src
/
VuFind
/
Record
/
Loader.php
119
10
VuFind
\
Record
\
Loader
load
/
module
/
VuFind
/
src
/
VuFind
/
Controller
/
AbstractRecord.php
617
9
VuFind
\
Controller
\
AbstractRecord
loadRecord
/
module
/
VuFind
/
src
/
VuFind
/
Controller
/
AbstractRecord.php
525
8
VuFind
\
Controller
\
AbstractRecord
exportAction
/
vendor
/
zendframework
/
zend-mvc
/
src
/
Controller
/
AbstractActionController.php
78
7
Zend
\
Mvc
\
Controller
\
AbstractActionController
onDispatch
/
vendor
/
zendframework
/
zend-eventmanager
/
src
/
EventManager.php
322
6
Zend
\
EventManager
\
EventManager
triggerListeners
/
vendor
/
zendframework
/
zend-eventmanager
/
src
/
EventManager.php
179
5
Zend
\
EventManager
\
EventManager
triggerEventUntil
/
vendor
/
zendframework
/
zend-mvc
/
src
/
Controller
/
AbstractController.php
104
4
Zend
\
Mvc
\
Controller
\
AbstractController
dispatch
/
vendor
/
zendframework
/
zend-mvc
/
src
/
DispatchListener.php
138
3
Zend
\
Mvc
\
DispatchListener
onDispatch
/
vendor
/
zendframework
/
zend-eventmanager
/
src
/
EventManager.php
322
2
Zend
\
EventManager
\
EventManager
triggerListeners
/
vendor
/
zendframework
/
zend-eventmanager
/
src
/
EventManager.php
179
1
Zend
\
EventManager
\
EventManager
triggerEventUntil
/
vendor
/
zendframework
/
zend-mvc
/
src
/
Application.php
332
0
Zend
\
Mvc
\
Application
run
/
public
/
index.php
71
/
usr
/
local
/
vufind
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
    }
 
    /**
     * If an unexpected exception type was received, wrap it in a generic
     * BackendException to standardize upstream handling.
     *
     * @param \Exception $ex Exception
     *
     * @return \Exception
     */
    protected function forceToBackendException($ex)
    {
        // Don't wrap specific backend exceptions....
        if ($ex instanceof RemoteErrorException
            || $ex instanceof RequestErrorException
            || $ex instanceof HttpErrorException
        ) {
            return $ex;
        }
        return new BackendException('Problem connecting to Solr.', null, $ex);
    }
 
    /**
     * Try all Solr URLs until we find one that works (or throw an exception).
     *
     * @param string   $method    HTTP method to use
     * @param string   $urlSuffix Suffix to append to all URLs tried
     * @param Callable $callback  Callback to configure client (null for none)
     *
     * @return string Response body
     *
     * @throws RemoteErrorException  SOLR signaled a server error (HTTP 5xx)
     * @throws RequestErrorException SOLR signaled a client error (HTTP 4xx)
     */
    protected function trySolrUrls($method, $urlSuffix, $callback = null)
    {
        // This exception should never get thrown; it's just a safety in case
        // something unanticipated occurs.
        $exception = new \Exception('Unexpected exception.');
 
/
usr
/
local
/
vufind
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
 
        // Loop through all base URLs and try them in turn until one works.
        foreach ((array)$this->url as $base) {
            $client = $this->createClient($base . $urlSuffix, $method);
            if (is_callable($callback)) {
                $callback($client);
            }
            try {
                return $this->send($client);
            } catch (\Exception $ex) {
                if ($this->isRethrowableSolrException($ex)) {
                    throw $this->forceToBackendException($ex);
                }
                $exception = $ex;
            }
        }
 
        // If we got this far, everything failed -- throw a BackendException with
        // the most recent exception caught above set as the previous exception.
        throw $this->forceToBackendException($exception);
    }
 
    /**
     * Send request the SOLR and return the response.
     *
     * @param HttpClient $client Prepared HTTP client
     *
     * @return string Response body
     *
     * @throws RemoteErrorException  SOLR signaled a server error (HTTP 5xx)
     * @throws RequestErrorException SOLR signaled a client error (HTTP 4xx)
     */
    protected function send(HttpClient $client)
    {
        $this->debug(
            sprintf('=> %s %s', $client->getMethod(), $client->getUri())
        );
 
        $time     = microtime(true);
        $response = $client->send();
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-http
/
src
/
Client
/
Adapter
/
Socket.php
                throw new AdapterException\InvalidArgumentException(sprintf(
                    'integer or numeric string expected, got %s',
                    gettype($connectTimeout)
                ));
            }
 
            ErrorHandler::start();
            $this->socket = stream_socket_client(
                $host . ':' . $port,
                $errno,
                $errstr,
                (int) $connectTimeout,
                $flags,
                $context
            );
            $error = ErrorHandler::stop();
 
            if (! $this->socket) {
                $this->close();
                throw new AdapterException\RuntimeException(
                    sprintf(
                        'Unable to connect to %s:%d%s',
                        $host,
                        $port,
                        ($error ? ' . Error #' . $error->getCode() . ': ' . $error->getMessage() : '')
                    ),
                    0,
                    $error
                );
            }
 
            // Set the stream timeout
            if (! stream_set_timeout($this->socket, (int) $this->config['timeout'])) {
                throw new AdapterException\RuntimeException('Unable to set the connection timeout');
            }
 
            if ($secure || $this->config['sslusecontext']) {
                if ($this->config['ssltransport'] && isset(static::$sslCryptoTypes[$this->config['ssltransport']])) {
                    $sslCryptoMethod = static::$sslCryptoTypes[$this->config['ssltransport']];
                } else {
Exception message: Unable to connect to localhost:8081 . Error #0: stream_socket_client(): unable to connect to localhost:8081 (Connection refused)
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-http
/
src
/
Client
/
Adapter
/
Socket.php
            if ($this->config['persistent']) {
                $flags |= STREAM_CLIENT_PERSISTENT;
            }
 
            if (isset($this->config['connecttimeout'])) {
                $connectTimeout = $this->config['connecttimeout'];
            } else {
                $connectTimeout = $this->config['timeout'];
            }
 
            if ($connectTimeout !== null && ! is_numeric($connectTimeout)) {
                throw new AdapterException\InvalidArgumentException(sprintf(
                    'integer or numeric string expected, got %s',
                    gettype($connectTimeout)
                ));
            }
 
            ErrorHandler::start();
            $this->socket = stream_socket_client(
                $host . ':' . $port,
                $errno,
                $errstr,
                (int) $connectTimeout,
                $flags,
                $context
            );
            $error = ErrorHandler::stop();
 
            if (! $this->socket) {
                $this->close();
                throw new AdapterException\RuntimeException(
                    sprintf(
                        'Unable to connect to %s:%d%s',
                        $host,
                        $port,
                        ($error ? ' . Error #' . $error->getCode() . ': ' . $error->getMessage() : '')
                    ),
                    0,
                    $error
                );
Exception message: stream_socket_client(): unable to connect to localhost:8081 (Connection refused)
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-http
/
src
/
Client
/
Adapter
/
Socket.php
            if ($this->config['persistent']) {
                $flags |= STREAM_CLIENT_PERSISTENT;
            }
 
            if (isset($this->config['connecttimeout'])) {
                $connectTimeout = $this->config['connecttimeout'];
            } else {
                $connectTimeout = $this->config['timeout'];
            }
 
            if ($connectTimeout !== null && ! is_numeric($connectTimeout)) {
                throw new AdapterException\InvalidArgumentException(sprintf(
                    'integer or numeric string expected, got %s',
                    gettype($connectTimeout)
                ));
            }
 
            ErrorHandler::start();
            $this->socket = stream_socket_client(
                $host . ':' . $port,
                $errno,
                $errstr,
                (int) $connectTimeout,
                $flags,
                $context
            );
            $error = ErrorHandler::stop();
 
            if (! $this->socket) {
                $this->close();
                throw new AdapterException\RuntimeException(
                    sprintf(
                        'Unable to connect to %s:%d%s',
                        $host,
                        $port,
                        ($error ? ' . Error #' . $error->getCode() . ': ' . $error->getMessage() : '')
                    ),
                    0,
                    $error
                );
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-http
/
src
/
Client.php
 
        return $parameters;
    }
 
    /**
     * Separating this from send method allows subclasses to wrap
     * the interaction with the adapter
     *
     * @param Http $uri
     * @param string $method
     * @param  bool $secure
     * @param array $headers
     * @param string $body
     * @return string the raw response
     * @throws Exception\RuntimeException
     */
    protected function doRequest(Http $uri, $method, $secure = false, $headers = [], $body = '')
    {
        // Open the connection, send the request and read the response
        $this->adapter->connect($uri->getHost(), $uri->getPort(), $secure);
 
        if ($this->config['outputstream']) {
            if ($this->adapter instanceof Client\Adapter\StreamInterface) {
                $this->streamHandle = $this->openTempStream();
                $this->adapter->setOutputStream($this->streamHandle);
            } else {
                throw new Exception\RuntimeException('Adapter does not support streaming');
            }
        }
        // HTTP connection
        $this->lastRawRequest = $this->adapter->write(
            $method,
            $uri,
            $this->config['httpversion'],
            $headers,
            $body
        );
 
        return $this->adapter->read();
    }
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-http
/
src
/
Client.php
            // headers
            $headers = $this->prepareHeaders($body, $uri);
 
            $secure = $uri->getScheme() == 'https';
 
            // cookies
            $cookie = $this->prepareCookies($uri->getHost(), $uri->getPath(), $secure);
            if ($cookie->getFieldValue()) {
                $headers['Cookie'] = $cookie->getFieldValue();
            }
 
            // check that adapter supports streaming before using it
            if (is_resource($body) && ! ($adapter instanceof Client\Adapter\StreamInterface)) {
                throw new Client\Exception\RuntimeException('Adapter does not support streaming');
            }
 
            $this->streamHandle = null;
            // calling protected method to allow extending classes
            // to wrap the interaction with the adapter
            $response = $this->doRequest($uri, $method, $secure, $headers, $body);
            $stream = $this->streamHandle;
            $this->streamHandle = null;
 
            if (! $response) {
                if ($stream !== null) {
                    fclose($stream);
                }
                throw new Exception\RuntimeException('Unable to read response, or response is empty');
            }
 
            if ($this->config['storeresponse']) {
                $this->lastRawResponse = $response;
            } else {
                $this->lastRawResponse = null;
            }
 
            if ($this->config['outputstream']) {
                if ($stream === null) {
                    $stream = $this->getStream();
                    if (! is_resource($stream) && is_string($stream)) {
/
usr
/
local
/
vufind
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
    }
 
    /**
     * Send request the SOLR and return the response.
     *
     * @param HttpClient $client Prepared HTTP client
     *
     * @return string Response body
     *
     * @throws RemoteErrorException  SOLR signaled a server error (HTTP 5xx)
     * @throws RequestErrorException SOLR signaled a client error (HTTP 4xx)
     */
    protected function send(HttpClient $client)
    {
        $this->debug(
            sprintf('=> %s %s', $client->getMethod(), $client->getUri())
        );
 
        $time     = microtime(true);
        $response = $client->send();
        $time     = microtime(true) - $time;
 
        $this->debug(
            sprintf(
                '<= %s %s', $response->getStatusCode(),
                $response->getReasonPhrase()
            ), ['time' => $time]
        );
 
        if (!$response->isSuccess()) {
            throw HttpErrorException::createFromResponse($response);
        }
        return $response->getBody();
    }
 
    /**
     * Create the HTTP client.
     *
     * @param string $url    Target URL
     * @param string $method Request method
/
usr
/
local
/
vufind
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
     *
     * @return string Response body
     *
     * @throws RemoteErrorException  SOLR signaled a server error (HTTP 5xx)
     * @throws RequestErrorException SOLR signaled a client error (HTTP 4xx)
     */
    protected function trySolrUrls($method, $urlSuffix, $callback = null)
    {
        // This exception should never get thrown; it's just a safety in case
        // something unanticipated occurs.
        $exception = new \Exception('Unexpected exception.');
 
        // Loop through all base URLs and try them in turn until one works.
        foreach ((array)$this->url as $base) {
            $client = $this->createClient($base . $urlSuffix, $method);
            if (is_callable($callback)) {
                $callback($client);
            }
            try {
                return $this->send($client);
            } catch (\Exception $ex) {
                if ($this->isRethrowableSolrException($ex)) {
                    throw $this->forceToBackendException($ex);
                }
                $exception = $ex;
            }
        }
 
        // If we got this far, everything failed -- throw a BackendException with
        // the most recent exception caught above set as the previous exception.
        throw $this->forceToBackendException($exception);
    }
 
    /**
     * Send request the SOLR and return the response.
     *
     * @param HttpClient $client Prepared HTTP client
     *
     * @return string Response body
     *
/
usr
/
local
/
vufind
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
     */
    public function query($handler, ParamBag $params)
    {
        $urlSuffix = '/' . $handler;
        $paramString = implode('&', $params->request());
        if (strlen($paramString) > self::MAX_GET_URL_LENGTH) {
            $method = Request::METHOD_POST;
            $callback = function ($client) use ($paramString) {
                $client->setRawBody($paramString);
                $client->setEncType(HttpClient::ENC_URLENCODED);
                $client->setHeaders(['Content-Length' => strlen($paramString)]);
            };
        } else {
            $method = Request::METHOD_GET;
            $urlSuffix .= '?' . $paramString;
            $callback = null;
        }
 
        $this->debug(sprintf('Query %s', $paramString));
        return $this->trySolrUrls($method, $urlSuffix, $callback);
    }
 
    /**
     * Check if an exception from a Solr request should be thrown rather than retried
     *
     * @param \Exception $ex Exception
     *
     * @return bool
     */
    protected function isRethrowableSolrException($ex)
    {
        return $ex instanceof TimeoutException
            || $ex instanceof RequestErrorException;
    }
 
    /**
     * If an unexpected exception type was received, wrap it in a generic
     * BackendException to standardize upstream handling.
     *
     * @param \Exception $ex Exception
/
usr
/
local
/
vufind
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Connector.php
    }
 
    /**
     * Return document specified by id.
     *
     * @param string   $id     The document to retrieve from Solr
     * @param ParamBag $params Parameters
     *
     * @return string
     */
    public function retrieve($id, ParamBag $params = null)
    {
        $params = $params ?: new ParamBag();
        $params
            ->set('q', sprintf('%s:"%s"', $this->uniqueKey, addcslashes($id, '"')));
 
        $handler = $this->map->getHandler(__FUNCTION__);
        $this->map->prepare(__FUNCTION__, $params);
 
        return $this->query($handler, $params);
    }
 
    /**
     * Return records similar to a given record specified by id.
     *
     * Uses MoreLikeThis Request Component or MoreLikeThis Handler
     *
     * @param string   $id     ID of given record (not currently used, but
     * retained for backward compatibility / extensibility).
     * @param ParamBag $params Parameters
     *
     * @return string
     *
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function similar($id, ParamBag $params)
    {
        $handler = $this->map->getHandler(__FUNCTION__);
        $this->map->prepare(__FUNCTION__, $params);
        return $this->query($handler, $params);
/
usr
/
local
/
vufind
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Backend
/
Solr
/
Backend.php
        $sort = "{$random}_random asc";
        $params->set('sort', $sort);
 
        return $this->search($query, 0, $limit, $params);
    }
 
    /**
     * Retrieve a single document.
     *
     * @param string   $id     Document identifier
     * @param ParamBag $params Search backend parameters
     *
     * @return RecordCollectionInterface
     */
    public function retrieve($id, ParamBag $params = null)
    {
        $params = $params ?: new ParamBag();
        $this->injectResponseWriter($params);
 
        $response   = $this->connector->retrieve($id, $params);
        $collection = $this->createRecordCollection($response);
        $this->injectSourceIdentifier($collection);
        return $collection;
    }
 
    /**
     * Retrieve a batch of documents.
     *
     * @param array    $ids    Array of document identifiers
     * @param ParamBag $params Search backend parameters
     *
     * @return RecordCollectionInterface
     */
    public function retrieveBatch($ids, ParamBag $params = null)
    {
        $params = $params ?: new ParamBag();
 
        // Load 100 records at a time; this is a good number to avoid memory
        // problems while still covering a lot of ground.
        $pageSize = 100;
/
usr
/
local
/
vufind
/
module
/
VuFindSearch
/
src
/
VuFindSearch
/
Service.php
    /**
     * Retrieve a single record.
     *
     * @param string   $backend Search backend identifier
     * @param string   $id      Record identifier
     * @param ParamBag $params  Search backend parameters
     *
     * @return RecordCollectionInterface
     */
    public function retrieve($backend, $id, ParamBag $params = null)
    {
        $params  = $params ?: new ParamBag();
        $context = __FUNCTION__;
        $args = compact('backend', 'id', 'params', 'context');
        $backend = $this->resolve($backend, $args);
        $args['backend_instance'] = $backend;
 
        $this->triggerPre($backend, $args);
        try {
            $response = $backend->retrieve($id, $params);
        } catch (BackendException $e) {
            $this->triggerError($e, $args);
            throw $e;
        }
        $this->triggerPost($response, $args);
        return $response;
    }
 
    /**
     * Retrieve a batch of records.
     *
     * @param string   $backend Search backend identifier
     * @param array    $ids     Record identifier
     * @param ParamBag $params  Search backend parameters
     *
     * @return RecordCollectionInterface
     */
    public function retrieveBatch($backend, $ids, ParamBag $params = null)
    {
        $params  = $params ?: new ParamBag();
/
usr
/
local
/
vufind
/
module
/
VuFind
/
src
/
VuFind
/
Record
/
Loader.php
     * @param string $id              Record ID
     * @param string $source          Record source
     * @param bool   $tolerateMissing Should we load a "Missing" placeholder
     * instead of throwing an exception if the record cannot be found?
     *
     * @throws \Exception
     * @return \VuFind\RecordDriver\AbstractBase
     */
    public function load($id, $source = DEFAULT_SEARCH_BACKEND,
        $tolerateMissing = false
    ) {
        if (null !== $id && '' !== $id) {
            $results = [];
            if (null !== $this->recordCache
                && $this->recordCache->isPrimary($source)
            ) {
                $results = $this->recordCache->lookup($id, $source);
            }
            if (empty($results)) {
                $results = $this->searchService->retrieve($source, $id)
                    ->getRecords();
            }
            if (empty($results) && null !== $this->recordCache
                && $this->recordCache->isFallback($source)
            ) {
                $results = $this->recordCache->lookup($id, $source);
            }
 
            if (!empty($results)) {
                return $results[0];
            }
        }
        if ($tolerateMissing) {
            $record = $this->recordFactory->get('Missing');
            $record->setRawData(['id' => $id]);
            $record->setSourceIdentifier($source);
            return $record;
        }
        throw new RecordMissingException(
            'Record ' . $source . ':' . $id . ' does not exist.'
/
usr
/
local
/
vufind
/
module
/
VuFind
/
src
/
VuFind
/
Controller
/
AbstractRecord.php
     * when homeAction() forwards to another method.
     *
     * @return AbstractRecordDriver
     */
    protected function loadRecord()
    {
        // Only load the record if it has not already been loaded.  Note that
        // when determining record ID, we check both the route match (the most
        // common scenario) and the GET parameters (a fallback used by some
        // legacy routes).
        if (!is_object($this->driver)) {
            $recordLoader = $this->getRecordLoader();
            $cacheContext = $this->getRequest()->getQuery()->get('cacheContext');
            if (isset($cacheContext)) {
                $recordLoader->setCacheContext($cacheContext);
            }
            $this->driver = $recordLoader->load(
                $this->params()->fromRoute('id', $this->params()->fromQuery('id')),
                $this->searchClassId,
                false
            );
        }
        return $this->driver;
    }
 
    /**
     * Redirect the user to the main record view.
     *
     * @param string $params Parameters to append to record URL.
     * @param string $tab    Record tab to display (null for default).
     *
     * @return mixed
     */
    protected function redirectToRecord($params = '', $tab = null)
    {
        $details = $this->getRecordRouter()
            ->getTabRouteDetails($this->loadRecord(), $tab);
        $target = $this->url()->fromRoute($details['route'], $details['params']);
 
        return $this->redirect()->toUrl($target . $params);
/
usr
/
local
/
vufind
/
module
/
VuFind
/
src
/
VuFind
/
Controller
/
AbstractRecord.php
    /**
     * Show citations for the current record.
     *
     * @return \Zend\View\Model\ViewModel
     */
    public function citeAction()
    {
        $view = $this->createViewModel();
        $view->setTemplate('record/cite');
        return $view;
    }
 
    /**
     * Export the record
     *
     * @return mixed
     */
    public function exportAction()
    {
        $driver = $this->loadRecord();
        $view = $this->createViewModel();
        $format = $this->params()->fromQuery('style');
 
        // Display export menu if missing/invalid option
        $export = $this->serviceLocator->get('VuFind\Export');
        if (empty($format) || !$export->recordSupportsFormat($driver, $format)) {
            if (!empty($format)) {
                $this->flashMessenger()
                    ->addMessage('export_invalid_format', 'error');
            }
            $view->setTemplate('record/export-menu');
            return $view;
        }
 
        // If this is an export format that redirects to an external site, perform
        // the redirect now (unless we're being called back from that service!):
        if ($export->needsRedirect($format)
            && !$this->params()->fromQuery('callback')
        ) {
            // Build callback URL:
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-mvc
/
src
/
Controller
/
AbstractActionController.php
     */
    public function onDispatch(MvcEvent $e)
    {
        $routeMatch = $e->getRouteMatch();
        if (! $routeMatch) {
            /**
             * @todo Determine requirements for when route match is missing.
             *       Potentially allow pulling directly from request metadata?
             */
            throw new Exception\DomainException('Missing route matches; unsure how to retrieve action');
        }
 
        $action = $routeMatch->getParam('action', 'not-found');
        $method = static::getMethodFromAction($action);
 
        if (! method_exists($this, $method)) {
            $method = 'notFoundAction';
        }
 
        $actionResponse = $this->$method();
 
        $e->setResult($actionResponse);
 
        return $actionResponse;
    }
}
 
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-eventmanager
/
src
/
EventManager.php
        }
 
        if ($this->sharedManager) {
            foreach ($this->sharedManager->getListeners($this->identifiers, $name) as $priority => $listeners) {
                $listOfListenersByPriority[$priority][] = $listeners;
            }
        }
 
        // Sort by priority in reverse order
        krsort($listOfListenersByPriority);
 
        // Initial value of stop propagation flag should be false
        $event->stopPropagation(false);
 
        // Execute listeners
        $responses = new ResponseCollection();
        foreach ($listOfListenersByPriority as $listOfListeners) {
            foreach ($listOfListeners as $listeners) {
                foreach ($listeners as $listener) {
                    $response = $listener($event);
                    $responses->push($response);
 
                    // If the event was asked to stop propagating, do so
                    if ($event->propagationIsStopped()) {
                        $responses->setStopped(true);
                        return $responses;
                    }
 
                    // If the result causes our validation callback to return true,
                    // stop propagation
                    if ($callback && $callback($response)) {
                        $responses->setStopped(true);
                        return $responses;
                    }
                }
            }
        }
 
        return $responses;
    }
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-eventmanager
/
src
/
EventManager.php
            $event->setParams($argv);
        }
 
        return $this->triggerListeners($event, $callback);
    }
 
    /**
     * @inheritDoc
     */
    public function triggerEvent(EventInterface $event)
    {
        return $this->triggerListeners($event);
    }
 
    /**
     * @inheritDoc
     */
    public function triggerEventUntil(callable $callback, EventInterface $event)
    {
        return $this->triggerListeners($event, $callback);
    }
 
    /**
     * @inheritDoc
     */
    public function attach($eventName, callable $listener, $priority = 1)
    {
        if (! is_string($eventName)) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s expects a string for the event; received %s',
                __METHOD__,
                (is_object($eventName) ? get_class($eventName) : gettype($eventName))
            ));
        }
 
        $this->events[$eventName][(int) $priority][0][] = $listener;
        return $listener;
    }
 
    /**
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-mvc
/
src
/
Controller
/
AbstractController.php
     * @events dispatch.pre, dispatch.post
     * @param  Request $request
     * @param  null|Response $response
     * @return Response|mixed
     */
    public function dispatch(Request $request, Response $response = null)
    {
        $this->request = $request;
        if (! $response) {
            $response = new HttpResponse();
        }
        $this->response = $response;
 
        $e = $this->getEvent();
        $e->setName(MvcEvent::EVENT_DISPATCH);
        $e->setRequest($request);
        $e->setResponse($response);
        $e->setTarget($this);
 
        $result = $this->getEventManager()->triggerEventUntil(function ($test) {
            return ($test instanceof Response);
        }, $e);
 
        if ($result->stopped()) {
            return $result->last();
        }
 
        return $e->getResult();
    }
 
    /**
     * Get request object
     *
     * @return Request
     */
    public function getRequest()
    {
        if (! $this->request) {
            $this->request = new HttpRequest();
        }
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-mvc
/
src
/
DispatchListener.php
            );
            return $this->complete($return, $e);
        } catch (\Throwable $exception) {
            $return = $this->marshalBadControllerEvent($controllerName, $e, $application, $exception);
            return $this->complete($return, $e);
        } catch (\Exception $exception) {  // @TODO clean up once PHP 7 requirement is enforced
            $return = $this->marshalBadControllerEvent($controllerName, $e, $application, $exception);
            return $this->complete($return, $e);
        }
 
        if ($controller instanceof InjectApplicationEventInterface) {
            $controller->setEvent($e);
        }
 
        $request  = $e->getRequest();
        $response = $application->getResponse();
        $caughtException = null;
 
        try {
            $return = $controller->dispatch($request, $response);
        } catch (\Throwable $ex) {
            $caughtException = $ex;
        } catch (\Exception $ex) {  // @TODO clean up once PHP 7 requirement is enforced
            $caughtException = $ex;
        }
 
        if ($caughtException !== null) {
            $e->setName(MvcEvent::EVENT_DISPATCH_ERROR);
            $e->setError($application::ERROR_EXCEPTION);
            $e->setController($controllerName);
            $e->setControllerClass(get_class($controller));
            $e->setParam('exception', $caughtException);
 
            $return = $application->getEventManager()->triggerEvent($e)->last();
            if (! $return) {
                $return = $e->getResult();
            }
        }
 
        return $this->complete($return, $e);
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-eventmanager
/
src
/
EventManager.php
        }
 
        if ($this->sharedManager) {
            foreach ($this->sharedManager->getListeners($this->identifiers, $name) as $priority => $listeners) {
                $listOfListenersByPriority[$priority][] = $listeners;
            }
        }
 
        // Sort by priority in reverse order
        krsort($listOfListenersByPriority);
 
        // Initial value of stop propagation flag should be false
        $event->stopPropagation(false);
 
        // Execute listeners
        $responses = new ResponseCollection();
        foreach ($listOfListenersByPriority as $listOfListeners) {
            foreach ($listOfListeners as $listeners) {
                foreach ($listeners as $listener) {
                    $response = $listener($event);
                    $responses->push($response);
 
                    // If the event was asked to stop propagating, do so
                    if ($event->propagationIsStopped()) {
                        $responses->setStopped(true);
                        return $responses;
                    }
 
                    // If the result causes our validation callback to return true,
                    // stop propagation
                    if ($callback && $callback($response)) {
                        $responses->setStopped(true);
                        return $responses;
                    }
                }
            }
        }
 
        return $responses;
    }
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-eventmanager
/
src
/
EventManager.php
            $event->setParams($argv);
        }
 
        return $this->triggerListeners($event, $callback);
    }
 
    /**
     * @inheritDoc
     */
    public function triggerEvent(EventInterface $event)
    {
        return $this->triggerListeners($event);
    }
 
    /**
     * @inheritDoc
     */
    public function triggerEventUntil(callable $callback, EventInterface $event)
    {
        return $this->triggerListeners($event, $callback);
    }
 
    /**
     * @inheritDoc
     */
    public function attach($eventName, callable $listener, $priority = 1)
    {
        if (! is_string($eventName)) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s expects a string for the event; received %s',
                __METHOD__,
                (is_object($eventName) ? get_class($eventName) : gettype($eventName))
            ));
        }
 
        $this->events[$eventName][(int) $priority][0][] = $listener;
        return $listener;
    }
 
    /**
/
usr
/
local
/
vufind
/
vendor
/
zendframework
/
zend-mvc
/
src
/
Application.php
            $response = $result->last();
            if ($response instanceof ResponseInterface) {
                $event->setName(MvcEvent::EVENT_FINISH);
                $event->setTarget($this);
                $event->setResponse($response);
                $event->stopPropagation(false); // Clear before triggering
                $events->triggerEvent($event);
                $this->response = $response;
                return $this;
            }
        }
 
        if ($event->getError()) {
            return $this->completeRequest($event);
        }
 
        // Trigger dispatch event
        $event->setName(MvcEvent::EVENT_DISPATCH);
        $event->stopPropagation(false); // Clear before triggering
        $result = $events->triggerEventUntil($shortCircuit, $event);
 
        // Complete response
        $response = $result->last();
        if ($response instanceof ResponseInterface) {
            $event->setName(MvcEvent::EVENT_FINISH);
            $event->setTarget($this);
            $event->setResponse($response);
            $event->stopPropagation(false); // Clear before triggering
            $events->triggerEvent($event);
            $this->response = $response;
            return $this;
        }
 
        $response = $this->response;
        $event->setResponse($response);
        return $this->completeRequest($event);
    }
 
    /**
     * Complete the request
/
usr
/
local
/
vufind
/
public
/
index.php
 
// Ensure vendor/ is on include_path; some PEAR components may not load correctly
// otherwise (i.e. File_MARC may cause a "Cannot redeclare class" error by pulling
// from the shared PEAR directory instead of the local copy):
$pathParts = [];
$pathParts[] = APPLICATION_PATH . '/vendor';
$pathParts[] = get_include_path();
set_include_path(implode(PATH_SEPARATOR, $pathParts));
 
// Composer autoloading
if (file_exists('vendor/autoload.php')) {
    $loader = include 'vendor/autoload.php';
}
 
if (!class_exists('Zend\Loader\AutoloaderFactory')) {
    throw new RuntimeException('Unable to load Zend Framework autoloader.');
}
 
// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
 
// Handle final profiling details, if necessary:
if ($xhprof) {
    $xhprofData = extension_loaded('xhprof') ? xhprof_disable() : tideways_disable();
    $xhprofRunId = uniqid();
    $suffix = 'vufind';
    $dir = ini_get('xhprof.output_dir');
    if (empty($dir)) {
        $dir = sys_get_temp_dir();
    }
    file_put_contents("$dir/$xhprofRunId.$suffix.xhprof", serialize($xhprofData));
    $url = "$xhprof?run=$xhprofRunId&source=$suffix";
    echo "<a href='$url'>Profiler output</a>";
}
 

Environment & details:

Key Value
style EndNoteWeb
empty
empty
empty
empty
Key Value
REDIRECT_SCRIPT_URL /vufind/Record/150174/Export
REDIRECT_SCRIPT_URI http://opac.cusat.ac.in/vufind/Record/150174/Export
REDIRECT_PERL5LIB /usr/share/koha/lib
REDIRECT_KOHA_CONF /etc/koha/sites/ul/koha-conf.xml
REDIRECT_MEMCACHED_SERVERS
REDIRECT_MEMCACHED_NAMESPACE
REDIRECT_VUFIND_ENV development
REDIRECT_VUFIND_LOCAL_DIR /usr/local/vufind/local
REDIRECT_STATUS 200
SCRIPT_URL /vufind/Record/150174/Export
SCRIPT_URI http://opac.cusat.ac.in/vufind/Record/150174/Export
PERL5LIB /usr/share/koha/lib
KOHA_CONF /etc/koha/sites/ul/koha-conf.xml
MEMCACHED_SERVERS
MEMCACHED_NAMESPACE
VUFIND_ENV development
VUFIND_LOCAL_DIR /usr/local/vufind/local
HTTP_ACCEPT */*
HTTP_USER_AGENT claudebot
HTTP_HOST opac.cusat.ac.in
PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
SERVER_SIGNATURE <address>Apache/2.4.41 (Ubuntu) Server at opac.cusat.ac.in Port 80</address>
SERVER_SOFTWARE Apache/2.4.41 (Ubuntu)
SERVER_NAME opac.cusat.ac.in
SERVER_ADDR 10.0.0.71
SERVER_PORT 80
REMOTE_ADDR 10.0.0.1
DOCUMENT_ROOT /usr/share/koha/opac/htdocs
REQUEST_SCHEME http
CONTEXT_PREFIX /vufind
CONTEXT_DOCUMENT_ROOT /usr/local/vufind/public
SERVER_ADMIN [no address given]
SCRIPT_FILENAME /usr/local/vufind/public/index.php
REMOTE_PORT 60976
REDIRECT_URL /vufind/Record/150174/Export
REDIRECT_QUERY_STRING style=EndNoteWeb
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING style=EndNoteWeb
REQUEST_URI /vufind/Record/150174/Export?style=EndNoteWeb
SCRIPT_NAME /vufind/index.php
PHP_SELF /vufind/index.php
REQUEST_TIME_FLOAT 1711655068.598
REQUEST_TIME 1711655068
empty
0. Whoops\Handler\PrettyPageHandler