Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v5
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -26,7 +26,7 @@ jobs:
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Yii Framework 2 HTTP client extension Change Log
2.0.17 under development
------------------------

- no changes in this release.
- Bug #250: Fixed `TypeError: stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given` in case PHP error reporting is turned off (shaperman)


2.0.16 February 13, 2025
Expand Down
7 changes: 7 additions & 0 deletions src/StreamTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,18 @@ public function send($request)
try {
$context = stream_context_create($contextOptions);
$stream = fopen($url, 'rb', false, $context);
if (false === $stream) {
$error = error_get_last();
throw new Exception(sprintf('Error while fopen(%s): %s', $url, isset($error['message']) ? $error['message'] : 'Unknown error'));
}
$responseContent = stream_get_contents($stream);
// see https://php.net/manual/en/reserved.variables.httpresponseheader.php
$responseHeaders = (array)$http_response_header;
fclose($stream);
} catch (\Exception $e) {
if (isset($stream) && is_resource($stream)) {
fclose($stream);
}
Yii::endProfile($token, __METHOD__);
throw new Exception($e->getMessage(), $e->getCode(), $e);
}
Expand Down
Loading