From dc1c640672c9589088575e22351ce749c90eae2b Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 24 May 2022 18:28:26 +0200 Subject: [PATCH 1/5] fixed psalm version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cda7c4f..26af517 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "test": "rm -f -r /tmp/cake* && phpunit", "coverage": "XDEBUG_MODE=coverage phpunit --coverage-html=coverage", "phpstan": "phpstan.phar analyse", - "psalm": "psalm.phar", + "psalm": "psalm.phar --php-version=8.0", "stan": [ "@stan-setup", "@phpstan", From fd88381653229b4f6458534f50d790b66eb1cc95 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 21 Jun 2022 17:10:43 +0200 Subject: [PATCH 2/5] updated --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 091696a..d297d00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: thumber-driver: 'gd' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Validate composer.json and composer.lock run: composer validate --strict @@ -81,7 +81,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -127,7 +127,7 @@ jobs: PHP_VERSION: '7.4' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 From 1d8053dd9a129aef767f3c416b2bfb4ad878f19a Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 21 Jun 2022 17:11:27 +0200 Subject: [PATCH 3/5] fixed --- tests/TestCase/Command/ClearAllCommandTest.php | 6 +----- tests/TestCase/Command/ClearCommandTest.php | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/TestCase/Command/ClearAllCommandTest.php b/tests/TestCase/Command/ClearAllCommandTest.php index 87c84e0..8349dde 100644 --- a/tests/TestCase/Command/ClearAllCommandTest.php +++ b/tests/TestCase/Command/ClearAllCommandTest.php @@ -24,16 +24,12 @@ /** * ClearAllCommandTest class + * @property \Thumber\Cake\Command\ClearAllCommand $Command */ class ClearAllCommandTest extends TestCase { use ConsoleIntegrationTestTrait; - /** - * @var \Thumber\Cake\Command\ClearAllCommand - */ - protected $Command; - /** * @var bool */ diff --git a/tests/TestCase/Command/ClearCommandTest.php b/tests/TestCase/Command/ClearCommandTest.php index a1af0b6..1f4508b 100644 --- a/tests/TestCase/Command/ClearCommandTest.php +++ b/tests/TestCase/Command/ClearCommandTest.php @@ -24,16 +24,12 @@ /** * ClearCommandTest class + * @property \Thumber\Cake\Command\ClearCommand $Command */ class ClearCommandTest extends TestCase { use ConsoleIntegrationTestTrait; - /** - * @var \Thumber\Cake\Command\ClearCommand - */ - protected $Command; - /** * @var bool */ From 387b93969156959a6ea2e1a258b60ab6d0a4ee53 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 21 Jun 2022 17:11:54 +0200 Subject: [PATCH 4/5] ready for CakePHP 4.4 --- CHANGELOG.md | 3 +++ src/Middleware/ThumbnailMiddleware.php | 9 +++++++-- tests/bootstrap.php | 2 +- version | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4567e8..a87336f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # 1.x branch ## 1.10 branch +### 1.10.1 +* ready for CakePHP 4.4. + ### 1.10.0 * requires at least PHP 7.4; * little fixes. diff --git a/src/Middleware/ThumbnailMiddleware.php b/src/Middleware/ThumbnailMiddleware.php index 53f749d..7e94aa8 100644 --- a/src/Middleware/ThumbnailMiddleware.php +++ b/src/Middleware/ThumbnailMiddleware.php @@ -15,6 +15,7 @@ */ namespace Thumber\Cake\Middleware; +use Cake\Core\Configure; use Cake\Http\Response; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -44,8 +45,12 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface $response = new Response(); $response = $response->withModified(filemtime($file) ?: 0); - if ($response->checkNotModified($request)) { - return $response; + /** + * @todo to be removed in a later version + */ + $method = version_compare(Configure::version(), '4.4', '>=') ? 'isNotModified' : 'checkNotModified'; + if ($response->$method($request)) { + return $response->withNotModified(); } return $response->withFile($file)->withType(mime_content_type($file) ?: ''); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3f7b6bc..6ebc622 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -66,7 +66,7 @@ 'serialize' => true, ], ]); -Configure::write('pluginsToLoad', ['Thumber/Cake']); +Configure::write('pluginsToLoad', ['Thumber\\Cake\\Plugin']); if (!getenv('THUMBER_DRIVER')) { putenv('THUMBER_DRIVER=' . (extension_loaded('imagick') ? 'imagick' : 'gd')); } diff --git a/version b/version index 81c871d..4dae298 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.10.0 +1.10.1 From 20ef9b7ec8f83cbcfd44dec7fc7861c7932ecafe Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 21 Jun 2022 17:14:43 +0200 Subject: [PATCH 5/5] fixed code --- tests/TestCase/Middleware/ThumbnailMiddlewareTest.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/TestCase/Middleware/ThumbnailMiddlewareTest.php b/tests/TestCase/Middleware/ThumbnailMiddlewareTest.php index 007f9a9..5a66fdb 100644 --- a/tests/TestCase/Middleware/ThumbnailMiddlewareTest.php +++ b/tests/TestCase/Middleware/ThumbnailMiddlewareTest.php @@ -47,15 +47,11 @@ public function testThumb(): void if (Configure::readOrFail('Thumber.driver') == 'imagick') { $extensions += [ 'bmp' => 'image/x-ms-bmp', - 'ico' => 'image/x-icon', + 'ico' => 'image/vnd.microsoft.icon', 'psd' => 'image/vnd.adobe.photoshop', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', ]; - - if (version_compare(PHP_VERSION, '7.4', '>=')) { - $extensions['ico'] = 'image/vnd.microsoft.icon'; - } } $ThumbHelper = new ThumbHelper(new View());