PHP 8.0.0 to PHP 8.0.25 - Object of class GdImage could not be converted to string
Zen Cart 1.5.7c
Database Patch Level: 1.5.7c
PHP Version: 8.0.25 (Zend: 4.0.25)
Server OS: Linux 4.18.0-372.32.1.lve.el8.x86_6
The PHP version on our shared server was upgrade from PHP 8.0.0 to PHP 8.0.25. I added a new product to my catalogue on the back-end, but when I try to open the new category on the front-end I get this error message in the logs:
PHP Fatal error: Uncaught Error: Object of class GdImage could not be converted to string in /home/ccfsecur/domains/ccfsecuritysystems.co.za/public_html/includes/classes/bmz_image_handler.class.php:851
Code:
protected function save_imageGD($file_ext, $image, $dest_name, $quality = 75)
{
// -----
// Initially, santitize the quality input for use by imagejpeg; values should
// be in the range 0-100.
//
$quality = (int)$quality;
if ($quality < 0 || $quality > 100) {
$quality = 75;
}
$this->ihLog("save_imageGD($file_ext, $image, $dest_name, $quality)");
switch (strtolower($file_ext)) {
case '.gif':
if (!function_exists('imagegif')) {
$this->ihLog("save_imageGD, imagegif function does not exist");
return false;
}
$ok = imagegif($image, $dest_name);
break;
case '.png':
if (!function_exists("imagepng")) {
$this->ihLog("save_imageGD, imagepng function does not exist");
return false;
}
// -----
// The quality input for imagepng requires an integer value in the
// range 0-9. If the value's out-of-range, use a proportional setting
// based on the input.
//
if ($quality > 9) {
$quality = (int)(9 * $quality / 100);
}
$ok = imagepng($image, $dest_name, $quality);
break;
case '.jpg':
case '.jpeg':
if (!function_exists("imagejpeg")) {
$this->ihLog("save_imageGD, imagejpeg function does not exist");
return false;
}
$ok = imagejpeg($image, $dest_name, $quality);
break;
default:
$ok = false;
break;
}
imagedestroy($image);
return $ok;
}
Line 851 is:
Code:
$this->ihLog("save_imageGD($file_ext, $image, $dest_name, $quality)");
I have just "comment out" line 851 by placing // informt of the code, and it seems to work. Did I do the right thing, or did I break something else?
I'm new to PHP, any assist will be appreciated.
Re: PHP 8.0.0 to PHP 8.0.25 - Object of class GdImage could not be converted to strin
Your Image Handler mod needs updating.