mirko-pagliai / cakephp-thumber

cakephp-thumber is a CakePHP plugin to create thumbnails
MIT License
7 stars 4 forks source link

v1.1.0 Breaks cakephp-thumber for CakePHP 3.8.x #69

Closed Mikescops closed 4 years ago

Mikescops commented 4 years ago

Updating php-thumber to the latest version breaks the cakephp plugin on 3.8.x (running PHP 7.4).

Error displayed > Declaration of Thumber\Cake\Utility\ThumbCreator::getImageInstance() must be compatible with Thumber\ThumbCreator::getImageInstance(): Intervention\Image\Image

mirko-pagliai commented 4 years ago

Hi @Mikescops

this seems inherent cakephp-thumber and not this package.

As explained in the readme file, you should use the cakephp3 branch.

Let me know if there are any problems.

Mikescops commented 4 years ago

Thanks for your quick reply!

Actually I'm using the 1.8.1 tag instead of cakephp3 branch because composer fails installing it due to conflict with dependencies. Can you confirm the cakephp3 branch works for you? I don't have much other dependencies than the default ones

mirko-pagliai commented 4 years ago

Can you confirm the cakephp3 branch works for you?

I do. It's not "for me": https://travis-ci.org/github/mirko-pagliai/cakephp-thumber/builds/640028439

Each branch of each of my plugins is tested: 1) with all versions of PHP 2) with all the lowest possible dependencies 3) with all the highest possible dependencies

In addition, this plugin is tested with both gd and imagick libraries. Just to avoid this kind of problem.

Actually I'm using the 1.8.1 tag instead of cakephp3 branch because composer fails installing it due to conflict with dependencies.

Okay, that's probably the problem. You are using a specific tag, so when you go to update packages, that package remains stationary, while its dependencies are updated (because that specific tag had no very tight dependencies). To avoid these kinds of problems, the cakephp3 branch was created.

So you can do two things: 1) try to solve the dependencies (if you want, paste your composer.json or the composer update output) 2) try composer require mirko-pagliai/php-thumber:~1.0.0, which is the version of php-thumber used by that branch ofcakephp-thumber

Mikescops commented 4 years ago

Ok thanks, it's good to know, I didn't see the CI.

Yes, I went for requiring the package php-thumber in the 1.0.1 version so it fixes the issue.

The purpose of this issue was more to understand the meaning of the displayed error than finding a temporary fix.

Declaration of Thumber\Cake\Utility\ThumbCreator::getImageInstance() must be compatible with Thumber\ThumbCreator::getImageInstance(): Intervention\Image\Image

But you're right it works like a charm with the correct version so I'm closing this issue as it's not generic. Thanks for the support and making this great plugin!

mirko-pagliai commented 4 years ago

The purpose of this issue was more to understand the meaning of the displayed error than finding a temporary fix.

PHP 7 introduced "return type declarations": https://www.php.net/manual/en/functions.returning-values.php

The latest versions of the packages (php-thumbs and cakephp-thumbs) are specific to PHP 7, because they use return type declarations. CakePHP 4 does it too.

So you're using a version of cakephp-thumber that doesn't use it and a version ofphp-thumber (the latest) that uses it.

So you have methods with a different signature: https://github.com/mirko-pagliai/cakephp-thumber/blob/1.8.1/src/Utility/ThumbCreator.php#L50 https://github.com/mirko-pagliai/php-thumber/blob/master/src/ThumbCreator.php#L117

Mikescops commented 4 years ago

Got it thanks!