Skip to content

Commit c327682

Browse files
authored
Merge pull request #30 from qiansheng91/fix/is_resource_incompatible
Fix issue that the is_resource() incompatible
2 parents 236df67 + 0a12f51 commit c327682

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Aliyun/Log/Models/Response/GetLogsResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public function __construct($resp, $header) {
6363
$this->count = $header['x-log-count'];
6464
$this->progress = $header ['x-log-progress'];
6565
$this->processedRows = $header['x-log-processed-rows'];
66-
$this->elapsedMilli = $header['x-log-elapsed-millisecond'];
67-
$this->cpuSec = $header['x-log-cpu-sec'];
68-
$this->cpuCores = $header['x-log-cpu-cores'];
66+
$this->elapsedMilli = $header['x-log-elapsed-millisecond']??0;
67+
$this->cpuSec = $header['x-log-cpu-sec']??0;
68+
$this->cpuCores = $header['x-log-cpu-cores']??0;
6969
$this->logs = array ();
7070
foreach ( $resp as $data ) {
7171
$contents = $data;

Aliyun/Log/requestcore.class.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,8 @@ public function process_response($curl_handle = null, $response = null)
765765
$this->response = $response;
766766
}
767767
// As long as this came back as a valid resource...
768-
if (is_resource($curl_handle))
768+
769+
if ($this->isCurlResource($curl_handle))
769770
{
770771
// Determine what's what.
771772
$header_size = curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE);
@@ -803,6 +804,19 @@ public function process_response($curl_handle = null, $response = null)
803804
return false;
804805
}
805806

807+
public static function isCurlResource($curlHandle): bool
808+
{
809+
if (\PHP_VERSION_ID < 80000) {
810+
return is_resource($curlHandle);
811+
} else {
812+
if(is_object($curlHandle) && get_class($curlHandle) == \CurlHandle::class) {
813+
return true;
814+
} else {
815+
return false;
816+
}
817+
}
818+
}
819+
806820
/**
807821
* Sends the request, calling necessary utility functions to update built-in properties.
808822
*

0 commit comments

Comments
 (0)