Skip to content

Commit 71c85e6

Browse files
authored
Merge pull request #61 from nguyenanhung/develop
Fix curl_close
2 parents 670a0ac + a15c5f5 commit 71c85e6

9 files changed

Lines changed: 33 additions & 14 deletions

helpers/ip_helper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ function getIpInformation($ip = '')
246246
));
247247
$response = curl_exec($curl);
248248
$err = curl_error($curl);
249-
curl_close($curl);
249+
if (PHP_VERSION_ID < 80000) {
250+
curl_close($curl);
251+
}
250252
if ($err) {
251253
$response = "cURL Error #:" . $err;
252254
}

helpers/request_helper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ function sendSimpleGetRequest($url = '', $data = array(), $method = 'GET')
5151
curl_setopt_array($curl, $options);
5252
$response = curl_exec($curl);
5353
$err = curl_error($curl);
54-
curl_close($curl);
54+
if (PHP_VERSION_ID < 80000) {
55+
curl_close($curl);
56+
}
5557
if ($err) {
5658
$message = "cURL Error #: " . $err;
5759
if (function_exists('log_message')) {

src/BaseHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
class BaseHelper
2121
{
22-
const VERSION = '1.7.0';
23-
const LAST_MODIFIED = '2025-03-15';
22+
const VERSION = '1.7.1';
23+
const LAST_MODIFIED = '2026-05-17';
2424
const PROJECT_NAME = 'CodeIgniter - Basic Helper';
2525
const AUTHOR_NAME = 'Hung Nguyen';
2626
const AUTHOR_FULL_NAME = 'Hung Nguyen';

src/BasicCurl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ public function reset()
700700
*/
701701
public function close()
702702
{
703-
if (is_resource($this->curl)) {
703+
if (PHP_VERSION_ID < 80000) {
704704
curl_close($this->curl);
705705
}
706706
return $this;

src/SimpleCurl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ public function createCurl($url = null)
314314

315315
public function closeCurl()
316316
{
317-
curl_close($this->session);
317+
if (PHP_VERSION_ID < 80000) {
318+
curl_close($this->session);
319+
}
318320
}
319321

320322
public function getHttpStatus()

src/SimpleElasticsearch.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ public function complexSearch(
146146
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
147147
}
148148

149-
curl_close($curl);
149+
if (PHP_VERSION_ID < 80000) {
150+
curl_close($curl);
151+
}
150152
if ($fullResponse === true) {
151153
return self::fullDataResponse($response, $page, $limit, $error_msg, $httpCode);
152154
}
@@ -205,7 +207,9 @@ public function filterSearch(
205207
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
206208
}
207209

208-
curl_close($curl);
210+
if (PHP_VERSION_ID < 80000) {
211+
curl_close($curl);
212+
}
209213
if ($fullResponse === true) {
210214
return self::fullDataResponse($response, $page, $limit, $error_msg, $httpCode);
211215
}
@@ -360,7 +364,9 @@ public function syncDataElasticsearch($data, $action, $id, $index)
360364
if (curl_errno($curl)) {
361365
$error_msg = curl_error($curl);
362366
}
363-
curl_close($curl);
367+
if (PHP_VERSION_ID < 80000) {
368+
curl_close($curl);
369+
}
364370

365371
if (isset($error_msg)) {
366372
// echo 'error sync :' . $id . '__:' . json_encode($error_msg) . 'id :' . $index . 'action :' . $action . PHP_EOL;
@@ -490,7 +496,9 @@ public static function createIndexElasticsearch($index, $listFields, $specialFie
490496
if (curl_errno($curl)) {
491497
$error_msg = curl_error($curl);
492498
}
493-
curl_close($curl);
499+
if (PHP_VERSION_ID < 80000) {
500+
curl_close($curl);
501+
}
494502

495503
if (isset($error_msg)) {
496504
// Log::info('error sync :' . $index . '__:' . json_encode($error_msg));

src/SimpleParseOpenGraph.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ static public function fetch($URI)
6363

6464

6565
$response = curl_exec($curl);
66-
67-
curl_close($curl);
66+
if (PHP_VERSION_ID < 80000) {
67+
curl_close($curl);
68+
}
6869

6970
if (!empty($response)) {
7071
return self::_parse($response);

src/SimpleRequests.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ public function xmlRequest($url = '', $data = '', $timeout = 60)
214214
curl_setopt($ch, CURLOPT_POST, 1);
215215
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
216216
$response = curl_exec($ch);
217-
curl_close($ch);
217+
if (PHP_VERSION_ID < 80000) {
218+
curl_close($ch);
219+
}
218220

219221
if ($this->DEBUG === true) {
220222
$this->logger->info('Response from Request: ' . $response);

src/SimpleRestful.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public static function execute($url, $type, $data = "", $header = null)
7373
$err = curl_error($curl);
7474
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
7575

76-
curl_close($curl);
76+
if (PHP_VERSION_ID < 80000) {
77+
curl_close($curl);
78+
}
7779

7880
if ($err) {
7981
echo "cURL Error #:" . $err;

0 commit comments

Comments
 (0)