From 950b1c40748ff83898cbec96a03adae94b0e29f8 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 17 Nov 2025 09:41:47 +0900 Subject: [PATCH] Don't use imagedestroy() in PHP 8.0 or higher --- classes/file/FileHandler.class.php | 37 +++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index 698b6470e..58c6898e2 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -657,8 +657,14 @@ class FileHandler $thumb = imagecreatetruecolor($resize_width, $resize_height); if (!$thumb) { - imagedestroy($source); - unset($source); + if (version_compare(PHP_VERSION, '8.0', '<')) + { + imagedestroy($source); + } + else + { + unset($source); + } return false; } @@ -719,8 +725,10 @@ class FileHandler imagecopyresampled($thumb, $source, $dst_x, $dst_y, 0, 0, $dst_width, $dst_height, $width, $height); } - imagedestroy($source); - unset($source); + if (version_compare(PHP_VERSION, '8.0', '>=')) + { + unset($source); + } // create directory self::makeDir(dirname($target_file)); @@ -752,14 +760,27 @@ class FileHandler } else { - imagedestroy($thumb); - unset($thumb); + if (version_compare(PHP_VERSION, '8.0', '<')) + { + imagedestroy($thumb); + } + else + { + unset($thumb); + } return false; } @chmod($target_file, 0666 & ~Rhymix\Framework\Storage::getUmask()); - imagedestroy($thumb); - unset($thumb); + + if (version_compare(PHP_VERSION, '8.0', '<')) + { + imagedestroy($thumb); + } + else + { + unset($thumb); + } return $output; }