mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-24 12:09:24 +00:00
Fix close() under PHP8
Fixes #662 At least on some platforms, maybe always with PHP8, is_resource(curl_init())===false because it returns the new \CurlHandle type instead.
This commit is contained in:
committed by
Zach Borboa
parent
75adc83a5c
commit
933e0bb76b
+4
-3
@@ -10,7 +10,7 @@ class Curl
|
||||
const VERSION = '8.9.0';
|
||||
const DEFAULT_TIMEOUT = 30;
|
||||
|
||||
public $curl;
|
||||
public $curl = null;
|
||||
public $id = null;
|
||||
|
||||
public $error = false;
|
||||
@@ -211,8 +211,9 @@ class Curl
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
if (is_resource($this->curl)) {
|
||||
if ($this->curl !== null) {
|
||||
curl_close($this->curl);
|
||||
$this->curl = null;
|
||||
}
|
||||
$this->options = null;
|
||||
$this->jsonDecoder = null;
|
||||
@@ -1457,7 +1458,7 @@ class Curl
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
if (function_exists('curl_reset') && is_resource($this->curl)) {
|
||||
if (function_exists('curl_reset') && $this->curl !== null) {
|
||||
curl_reset($this->curl);
|
||||
} else {
|
||||
$this->curl = curl_init();
|
||||
|
||||
@@ -7,7 +7,7 @@ use Curl\ArrayUtil;
|
||||
class MultiCurl
|
||||
{
|
||||
public $baseUrl = null;
|
||||
public $multiCurl;
|
||||
public $multiCurl = null;
|
||||
|
||||
private $curls = array();
|
||||
private $activeCurls = array();
|
||||
@@ -370,8 +370,9 @@ class MultiCurl
|
||||
$curl->close();
|
||||
}
|
||||
|
||||
if (is_resource($this->multiCurl)) {
|
||||
if ($this->multiCurl !== null) {
|
||||
curl_multi_close($this->multiCurl);
|
||||
$this->multiCurl = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user