Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This is the Developer Changelog for Matomo PHP Tracker. All breaking changes or new features are listed below.

## Matomo PHP Tracker 3.3.1
### Fixed
- closed curl connection

## Matomo PHP Tracker 3.3.0
### Removed
- support for PHP versions lower than 7.2
Expand Down
38 changes: 21 additions & 17 deletions MatomoTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2012,36 +2012,40 @@ protected function sendRequest($url, $method = 'GET', $data = null, $force = fal
}
}

$content = '';

if (function_exists('curl_init') && function_exists('curl_exec')) {
$options = $this->prepareCurlOptions($url, $method, $data, $forcePostUrlEncoded);

$ch = curl_init();
curl_setopt_array($ch, $options);
ob_start();
$response = @curl_exec($ch);
ob_end_clean();

$header = '';
$content = '';
try {
$header = '';

if ($response === false) {
$curlError = curl_error($ch);
if (!empty($curlError)) {
throw new \RuntimeException($curlError);
if ($response === false) {
$curlError = curl_error($ch);
if (!empty($curlError)) {
throw new \RuntimeException($curlError);
}
}
}

if (!empty($response)) {
// extract header
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $headerSize);

// extract content
$content = substr($response, $headerSize);
}
if (!empty($response)) {
// extract header
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $headerSize);

$this->parseIncomingCookies(explode("\r\n", $header));
// extract content
$content = substr($response, $headerSize);
}

$this->parseIncomingCookies(explode("\r\n", $header));
} finally {
curl_close($ch);
ob_end_clean();
}
} elseif (function_exists('stream_context_create')) {
$stream_options = $this->prepareStreamOptions($method, $data, $forcePostUrlEncoded);

Expand Down