diff --git a/config/vufind/config.ini b/config/vufind/config.ini index f067db36464a59db50475daa74259b0ba90dce18..6e172c934ae0e652d2eaffea489ddec5029c690b 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -591,6 +591,8 @@ authors = Wikipedia use_ssl = false plus = false ;plus_id = "MySyndeticsId" +; timeout value (in seconds) for API calls: +timeout = 10 ; Booksite CATS Enhanced Content - cover images, reviews, description, etc. [Booksite] diff --git a/module/VuFind/src/VuFind/Content/AbstractSyndetics.php b/module/VuFind/src/VuFind/Content/AbstractSyndetics.php index acfd53f23f32a2ee5734ddd80362f370e01a711e..8ba8431c1fac103733497b0a97b0460ae8d65511 100644 --- a/module/VuFind/src/VuFind/Content/AbstractSyndetics.php +++ b/module/VuFind/src/VuFind/Content/AbstractSyndetics.php @@ -53,16 +53,40 @@ abstract class AbstractSyndetics extends AbstractBase */ protected $usePlus; + /** + * HTTP timeout for API calls (in seconds) + * + * @var int + */ + protected $timeout; + /** * Constructor * * @param bool $useSSL Use SSL URLs? * @param bool $usePlus Use Syndetics Plus? + * @param int $timeout HTTP timeout for API calls (in seconds) */ - public function __construct($useSSL = false, $usePlus = false) + public function __construct($useSSL = false, $usePlus = false, $timeout = 10) { $this->useSSL = $useSSL; $this->usePlus = $usePlus; + $this->timeout = $timeout; + } + + /** + * Get an HTTP client + * + * @param string $url URL for client to use + * + * @return \Zend\Http\Client + * @throws \Exception + */ + protected function getHttpClient($url) + { + $client = parent::getHttpClient($url); + $client->setOptions(array('timeout' => $this->timeout)); + return $client; } /** diff --git a/module/VuFind/src/VuFind/Content/AuthorNotes/Factory.php b/module/VuFind/src/VuFind/Content/AuthorNotes/Factory.php index b41e185b0a177babc9c8e0dbfd142f18f8a529f6..4b61bba1ec66e732df4b51db7733e774bcea01c2 100644 --- a/module/VuFind/src/VuFind/Content/AuthorNotes/Factory.php +++ b/module/VuFind/src/VuFind/Content/AuthorNotes/Factory.php @@ -52,7 +52,8 @@ class Factory $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); return new Syndetics( isset($config->Syndetics->use_ssl) && $config->Syndetics->use_ssl, - $plus + $plus, + isset($config->Syndetics->timeout) ? $config->Syndetics->timeout : 10 ); } diff --git a/module/VuFind/src/VuFind/Content/Excerpts/Factory.php b/module/VuFind/src/VuFind/Content/Excerpts/Factory.php index 2334641c3ead006dcc6e12cdea618e33b737dd41..96155ceb630d5c9dfde5be58b655c890dc3d6fca 100644 --- a/module/VuFind/src/VuFind/Content/Excerpts/Factory.php +++ b/module/VuFind/src/VuFind/Content/Excerpts/Factory.php @@ -52,7 +52,8 @@ class Factory $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); return new Syndetics( isset($config->Syndetics->use_ssl) && $config->Syndetics->use_ssl, - $plus + $plus, + isset($config->Syndetics->timeout) ? $config->Syndetics->timeout : 10 ); } diff --git a/module/VuFind/src/VuFind/Content/Reviews/Factory.php b/module/VuFind/src/VuFind/Content/Reviews/Factory.php index 72c0714235eebba36c386610b2f29204e4a46f7f..ac155abdc7ee5364b1bcfdda1be80e53d75d0af7 100644 --- a/module/VuFind/src/VuFind/Content/Reviews/Factory.php +++ b/module/VuFind/src/VuFind/Content/Reviews/Factory.php @@ -52,7 +52,8 @@ class Factory $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); return new Syndetics( isset($config->Syndetics->use_ssl) && $config->Syndetics->use_ssl, - $plus + $plus, + isset($config->Syndetics->timeout) ? $config->Syndetics->timeout : 10 ); }