Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ public function __construct(\CyberSource\Configuration $config = null, \CyberSou
echo "Merchant Configuration cannot be null.";
}

if (self::$shareHandle === null) {
// Connection sharing needs PHP built against libcurl >= 7.57.0, where
// CURL_LOCK_DATA_CONNECT exists. Older builds simply skip the share
// handle instead of failing with an undefined constant.
if (self::$shareHandle === null && defined('CURL_LOCK_DATA_CONNECT')) {
self::$shareHandle = curl_share_init();
curl_share_setopt(self::$shareHandle, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
}
Expand Down Expand Up @@ -318,7 +321,9 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header

$curl = curl_init();

curl_setopt($curl, CURLOPT_SHARE, self::$shareHandle);
if (self::$shareHandle !== null) {
curl_setopt($curl, CURLOPT_SHARE, self::$shareHandle);
}
// set timeout, if needed
if ($this->config->getCurlTimeout() !== 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
Expand Down