Topic: Showkase and PHP

Steven @ Showkase wrote:

The current version of Showkase (v1.7.6) is fully compatible with PHP 8.0 and 8.1

There is, however, a compatibility problem with PHP 8.2 (due to a deprecated feature) but I have notified the developers of this and it should be fixed in due course.
Until such time, just use PHP 8.0 or 8.1 (or, indeed, any version of PHP between 5.2 and 8.1 inclusive) and you'll be fine.

my hosting service provider asks me to change to PHP 8.0 or 8.1 because the one that currently uses PHP 7.4 will no longer be maintained. When doing so, my access to manage the web stopped working, possibly due to compatibility problems between the Showkase-Pro 1.7.3 version (which I currently use) and PHP 8.0 or 8.1. Could you confirm if that could be the problem and if so, how do I update the Showkase version (and what are the risks)?

Re: Showkase and PHP

my hosting service provider asks me to change to PHP 8.0 or 8.1 because the one that currently uses PHP 7.4 will no longer be maintained. When doing so, my access to manage the web stopped working, possibly due to compatibility problems between the Showkase-Pro 1.7.3 version (which I currently use) and PHP 8.0 or 8.1. Could you confirm if that could be the problem and if so, how do I update the Showkase version (and what are the risks)?

Re: Showkase and PHP

@MBene

Could you confirm if that could be the problem...

The only version of Showkase which is fully compatible with PHP 8.0 and 8.1 is the latest version (Showkase v1.7.6) so the use of Showkase v1.7.3 under PHP 8.0/8.1 could be the problem (though I can't be 100% sure).
Are you able to check your web server logs and browser developer tools console to see if you can find any warning or error messages that would give a reason for the problem? If we know exactly what the problem is, we'd have a better chance of figuring out how to fix it.

I'd certainly recommend upgrading Showkase to see if this resolves the issue.
Instructions for upgrading Showkase can be found here.

Upgrading is essentially just a case of uploading the new Showkase source files on top of the existing installation so it should be a fairly quick and easy (and risk-free) process. You should not lose any custom data or pages (only source files are overwritten). (See link above for full details.) Having said, that, I'd strongly recommend that you make a complete backup of your existing site first. Please check the notes below.

Notes:

(1) When upgrading your Showkase site, please be sure to make a complete backup of your existing site first, just in case anything should go wrong and you need to reinstate your original files at a later date. You should not encounter any problems upgrading Showkase but it would be wise to have a backup of your site should anything unexpected happen. Also, if you have made manual customizations to any Showkase source files or have used your theme's custom.css or custom.js files, then please note that these will be overwritten when you upgrade and you'll need a backup in order to reinstate them afterwards.

(2) Please remember that Showkase-Standard comes bundled with Juicebox-Lite (the free version of Juicebox) so, if you have purchased Showkase-Standard and Juicebox-Pro separately, then after upgrading your Showkase site, you'll need to reinstate your Juicebox-Pro files by following the Installing Juicebox Pro instructions here.

(I included these notes are they might help others reading this thread. I know that you are a Showkase-Pro user and that Note #2 is not relevant to your case.)

I have sent you a new download link for your Showkase-Pro purchase so that you can download the latest version of Showkase (v1.7.6). (Download links always point towards the latest version rather than the version you purchased.)

I hope this helps but if you continue to experience difficulties, please post back to let me know (with further details of the problem, if possible) and I'll try to help further.
Thank you.

Re: Showkase and PHP

I have upgraded to Showkase 1.7.6, and with PHP 8.1 I get an error when uploading some images to the web (not all, a third of them). The error is: "Unable to create new thumbnail(implicit conversion from float 0.5 to int loses precision) in thumbnail php, line 133".
I'm not good at attaching images to the forum, perhaps if you provided me with an email address I could easily send them to you.

Re: Showkase and PHP

Unfortunately, it looks like you've run into an issue which no-one has reported before (most likely due to this deprecation in PHP 8.1).

I've not been able to replicate the problem myself with a batch of test images running Showkase-Pro v1.7.6 under PHP 8.1.1.

You can find my email address in the column to the left of this post (just look for and click the word 'Email'). You'll need to be logged into the forum to see this.

I might be able to replicate the problem if I know the original dimensions of the source images that fail and your chosen resize dimension (but it would be better if I had access to the images that fail).

Please email me the images that fail if you can and I'll follow this up as soon as possible.
Thank you.

Re: Showkase and PHP

Hi Steven. I have looked for your email address but I could not find it in the post. Since you helped me with a similar problem years ago, I have sent you an email with the images and errors to the address I keep from then (Sep 2018). Please confirm if you have received it and if not, send me an email to be connected (miguel.benedicto@telefonica.net).

Re: Showkase and PHP

I have looked for your email address but I could not find it in the post.

That's odd. It should be located below my username to the left of each post.

Anyway, thank you for providing such a clear explanation of the problem and some source images.
I've been able to replicate the problem (it's due to the deprecation I noted above) and have formulated a fix.

Until the fix can be integrated into a new version of Showkase, here are the details:

(1) Open your Showkase site's admin/classes/thumbnail.php file in a plain text editor.

(2) Change line 83 from:

$deltaY = ($imageHeight - $cropHeight)/2;

... to:

$deltaY = (int)(($imageHeight - $cropHeight) / 2);

(3) Change line 88 from:

$deltaX = ($imageWidth - $cropWidth)/2;

... to:

$deltaX = (int)(($imageWidth - $cropWidth) / 2);

(4) Save the 'thumbnail.php' file with the changes above and re-upload it to your Showkase site's admin/classes/ folder, overwriting the existing 'thumbnail.php' file.

Thank you for bringing this to our attention and apologies for any inconvenience caused.

Incidentally, the line numbers above refer to the current version of Showakse (v1.7.6).

Re: Showkase and PHP

Thanks Steven,

After replacing the Thumbnail.php file with the one you send me, I have retested all three images. Two of them have loaded without problem, but Image2 continues to give an error (in the same step, but different number than the one it gave yesterday). It seems that the solution has been partial. I have send you an email with the details.

Re: Showkase and PHP

That's strange.
I tested the fix with all three of your source images yesterday and all three images uploaded without issue.
I've just checked again today with 'Image2.jpg' from your most recent email and, again, it works without any errors or warnings at all.
(I've been testing with Showkase v1.7.6 under PHP 8.1.1.6.)

There must be some other difference between our setups that is causing the problem but not being able to replicate the problem makes troubleshooting difficult.

What version of PHP are you using? Is it PHP 8.1.0 or another version in the 8.1 branch?
Do you have any custom image sizes set within Showkase or are all image sizes defaults?
Do you have any other images that still fail (with the fix in place) that I can use to test with? Maybe I'll see a pattern in all the images that fail.

I'll keep looking at this but if you can provide any further information that might help me to pinpoint the problem (or replicate it), then that would be great.
Thanks.

Re: Showkase and PHP

Hi Steven, I have sent you a new email with other images that give me an error and some more details. See if you can identify the problem. Thank you.

Re: Showkase and PHP

Hi again Steven, I have sent you a second email with some clues found in new tests that I have carried out, related to the parameters established for the generation of thumbnails. Let's see if they help for the analysis.

Thanks again.

Re: Showkase and PHP

Thank you, once again, for all the information that you have provided. It really does make troubleshooting that much easier.

I was instantly able to replicate the problem by setting thumbnail dimensions of 81 x 54 and I see that I overlooked a couple of other variables (cropHeight and cropWidth) that could potentially not be integers (where integers are required).

However, rather than changing their definitions in the code (like I did previously for deltaX and deltaY in my original fix), it might be better to ensure that all numeric variables are integers for the two functions that require integers, which will also cover the edge case of a user entering decimal values for thumbnail dimensions in the Showkase interface (which, ideally, should not happen but is technically possible).

So, here's a new fix.
From a fresh, unmodified 'thumbnail.php' file:

(1) Change line 110 from:

$imageDest = imagecreatetruecolor($thumbWidth, $thumbHeight);

... to:

$imageDest = imagecreatetruecolor((int)$thumbWidth, (int)$thumbHeight);

(2) Change line 116 from:

if (!imagecopyresampled($imageDest, $imageSrc, 0, 0, $deltaX, $deltaY, $thumbWidth, $thumbHeight, $cropWidth, $cropHeight)) {

... to:

if (!imagecopyresampled($imageDest, $imageSrc, 0, 0, (int)$deltaX, (int)$deltaY, (int)$thumbWidth, (int)$thumbHeight, (int)$cropWidth, (int)$cropHeight)) {

I hope this completely fixes the problem this time around.
Thanks again for your help and for reporting the problem in the first instance.

Re: Showkase and PHP

Hello Steven,
It seems that everything is working correctly now. Thank you very much for your help.

Re: Showkase and PHP

That's good to hear. Thanks for testing!

I've notified the developers of this fix so it will be included in the next version (but I don't know when this might be).

Best wishes!

Re: Showkase and PHP

I had this exact same problem, thanks for the fix.

Re: Showkase and PHP

@petax

I'll glad the fix helped. Thank you for letting me know.

Re: Showkase and PHP

@Koinelendot

It's a shame that a new version of Showkase has not yet been released with an implementation of the fix above but my code (from this post) is a complete solution to the problem with no known adverse side affects for those experiencing (or not experiencing) the problem.