[WEB-19] Handle missing ext-curl by checking CURLOPT_TIMEOUT constant

This commit is contained in:
Piotr Marynczak committed 2026-09-03 11:40:36 +02:00
1 parent 23002b7149
commit aa75bb0e23
2 files changed
+12 -1

No files matched your search

+4 -1
View File
@@ -120,8 +120,11 @@ class JsonRpcClientManager
* `JsonRPC\HttpClient` doesn't set `CURLOPT_TIMEOUT` (limit of the whole request, including reading
* the response) at all by default, so without this a slow/unresponsive LimeSurvey instance could hang
* the request for a very long time.
*
* `CURLOPT_TIMEOUT` is only defined when ext-curl is loaded, so the option is skipped in stream-based
* environments to avoid a fatal error on the undefined constant.
*/
if (null !== $this->connectionConfiguration->getRequestTimeout()) {
if (null !== $this->connectionConfiguration->getRequestTimeout() && defined('CURLOPT_TIMEOUT')) {
$this
->rpcClient
->getHttpClient()
@@ -113,6 +113,10 @@ class JsonRpcClientManagerTest extends BaseTestCase
public function testGetRpcClientWithoutTimeoutsDoesNotTouchHttpClientDefaults()
{
if (!extension_loaded('curl')) {
$this->markTestSkipped('ext-curl is required to assert CURLOPT_TIMEOUT options.');
}
$configuration = new ConnectionConfiguration('http://test.com', 'test', 'test');
$httpClient = $this->getHttpClientOfManager(new JsonRpcClientManager($configuration));
@@ -122,6 +126,10 @@ class JsonRpcClientManagerTest extends BaseTestCase
public function testGetRpcClientAppliesConnectAndRequestTimeout()
{
if (!extension_loaded('curl')) {
$this->markTestSkipped('ext-curl is required to assert CURLOPT_TIMEOUT options.');
}
$configuration = new ConnectionConfiguration('http://test.com', 'test', 'test', false, true, 2, 7);
$httpClient = $this->getHttpClientOfManager(new JsonRpcClientManager($configuration));