Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a9bea5

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents faf3f37 + 165f06a commit 9a9bea5

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/Request.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ protected function requestCore($url, $params = [], $is_use_method = false) {
7171
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
7272
$json_result = curl_exec($ch);
7373
$result = json_decode($json_result, true);
74+
$errorCode = curl_errno($ch);
7475

75-
curl_close($ch);
76+
unset($ch);
7677
$is_json_error = (json_last_error() !== JSON_ERROR_NONE);
7778

7879
if (isset($result['error']) && self::$error_suppression) {
@@ -82,7 +83,7 @@ protected function requestCore($url, $params = [], $is_use_method = false) {
8283
//при отправке peer_ids возвращается response[0], response[1]['error'] ... для каждого id
8384
//тут это не обрабатывается и ошибка не вызывается
8485

85-
if (isset($result['error']) || !isset($result) || $is_json_error || curl_errno($ch)) {
86+
if (isset($result['error']) || !isset($result) || $is_json_error || $errorCode) {
8687
if($is_use_method) {
8788
$access_token = substr($params['access_token'], 0, 10) . '****';
8889
$v = $params['v'];
@@ -103,8 +104,6 @@ protected function requestCore($url, $params = [], $is_use_method = false) {
103104
$params['url'] = $url;
104105
}
105106

106-
$errorCode = curl_errno($ch);
107-
108107
if($errorCode == CURLE_COULDNT_CONNECT ||$errorCode == CURLE_COULDNT_RESOLVE_HOST) {
109108
$error_code = 77779;
110109
throw new SimpleVkException($error_code, 'Нет соедиения с сервером VK API. Проверьте доступность сети.');
@@ -155,4 +154,4 @@ public static function setProxy($proxy, $pass = false) {
155154
if ($pass)
156155
self::$proxy['user_pwd'] = $pass;
157156
}
158-
}
157+
}

0 commit comments

Comments
 (0)