Skip to content

Commit 459e094

Browse files
authored
Merge pull request #235 from plank/fix-load-image-contents
Load intervention image with file contents instead of stream
2 parents 5736de8 + ccf0c76 commit 459e094

File tree

5 files changed

+71
-23
lines changed

5 files changed

+71
-23
lines changed

.github/workflows/automated-test.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: PHPUnit Tests
2+
on: [push]
3+
jobs:
4+
phpunit:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
php-versions: ['7.3', '7.4']
9+
prefer-lowest: ['','--prefer-lowest']
10+
name: PHP ${{ matrix.php-versions }} ${{ matrix.prefer-lowest }}
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: ${{ matrix.php-versions }}
19+
extensions: gd
20+
coverage: pcov
21+
env:
22+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Get composer cache directory
25+
id: composer-cache
26+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
27+
28+
- name: Cache dependencies
29+
uses: actions/cache@v2
30+
with:
31+
path: ${{ steps.composer-cache.outputs.dir }}
32+
key: ${{ runner.os }}-${{ matrix.php-version }}${{ matrix.prefer-lowest }}-composer-${{ hashFiles('**/composer.json') }}
33+
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}${{ matrix.prefer-lowest }}-composer-
34+
35+
- name: Install dependencies
36+
run: composer update --prefer-dist ${{ matrix.prefer-lowest }}
37+
env:
38+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Run phpunit
41+
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml -v
42+
env:
43+
S3_KEY: ${{ secrets.S3_KEY }}
44+
S3_SECRET: ${{ secrets.S3_SECRET }}
45+
S3_REGION: ${{ secrets.S3_REGION }}
46+
S3_BUCKET: ${{ secrets.S3_BUCKET }}
47+
48+
- name: Upload coverage results to Coveralls
49+
env:
50+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
COVERALLS_PARALLEL: true
52+
COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }} ${{ matrix.prefer-lowest }}
53+
run: vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml
54+
55+
finish-coverage:
56+
needs: phpunit
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Coveralls Finished
60+
uses: coverallsapp/github-action@master
61+
with:
62+
github-token: ${{ secrets.GITHUB_TOKEN }}
63+
parallel-finished: true

.travis.yml

-18
This file was deleted.

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
"guzzlehttp/guzzle": "^6.5|^7.1"
2222
},
2323
"require-dev": {
24-
"orchestra/testbench": "^4.0|^5.0|^6.0",
25-
"phpunit/phpunit": "^8.2.4|^9.0",
24+
"orchestra/testbench": "^5.9|^6.6",
25+
"phpunit/phpunit": "^9.5",
2626
"vlucas/phpdotenv": "^4.0|^5.0",
2727
"league/flysystem-aws-s3-v3" : "^1.0.23",
2828
"guzzlehttp/promises": "^1.3",
2929
"aws/aws-sdk-php": "^3.128.0",
30-
"php-coveralls/php-coveralls": "^2.1",
30+
"php-coveralls/php-coveralls": "^2.4",
3131
"laravel/legacy-factories": "^1.0.4",
3232
"doctrine/dbal": "^2.11"
3333
},

src/ImageManipulator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function createImageVariant(
9393
$manipulation = $this->getVariantDefinition($variantName);
9494

9595
$outputFormat = $this->determineOutputFormat($manipulation, $media);
96-
$image = $this->imageManager->make($media->stream());
96+
$image = $this->imageManager->make($media->contents());
9797

9898
$callback = $manipulation->getCallback();
9999
$callback($image);

src/SourceAdapters/RemoteUrlAdapter.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ private function getHeader($key, $default = null): ?string
138138
*/
139139
public function getHeaders(): array
140140
{
141-
$headers = @get_headers($this->source, 1);
141+
$headers = @get_headers(
142+
$this->source,
143+
version_compare(phpversion(), '8.0.0', '>=') ? true : 1
144+
);
142145

143146
return $headers ?: [];
144147
}

0 commit comments

Comments
 (0)