From b89b26ac476b526562661cc592ff848f0a711307 Mon Sep 17 00:00:00 2001 From: J5lx Date: Thu, 14 Aug 2014 21:59:31 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20close=20the=20cURL=20handle=20m?= =?UTF-8?q?ore=20than=20once?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When close() was called more than once PHP warnings appeared stating that "XY is not a valid cURL handle resource". This was especially problematic when close() was called manually because it will also *always* be called from the destructor. From no on we’ll first check whether $this->curl is still a resource to avoid that. --- src/Curl/Curl.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 48b6ae5..e9e2a78 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -121,7 +121,9 @@ public function verbose($on=TRUE) { } public function close() { - curl_close($this->curl); + if (is_resource($this->curl)) { + curl_close($this->curl); + } } public function _exec() {