From 8fe5e5b08da3ea1ce0abce9dc7910cd3e063cada Mon Sep 17 00:00:00 2001 From: tombrain Date: Sun, 1 Nov 2026 14:07:21 +0100 Subject: [PATCH 1/3] fix: UploadField uses finfo as an object, finfo_close() is deprecated in PHP 8.5 --- CHANGELOG.md | 7 +++++++ src/fields/class.UploadField.php | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e8abc7..69024c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project follows [Semantic Versioning](https://semver.org/). +## [4.8.1] - unreleased + +### Fixed + +- `UploadField` uses `finfo` as an object to get the mime type of the file. `finfo_close()` + is deprecated as of PHP 8.5, so every upload with a type check gave a deprecation notice. + ## [4.8.0] - 2026-11-01 ### Added diff --git a/src/fields/class.UploadField.php b/src/fields/class.UploadField.php index 6891ae6..f266660 100644 --- a/src/fields/class.UploadField.php +++ b/src/fields/class.UploadField.php @@ -540,12 +540,12 @@ public function isValid() // does build in function exists for retrieving the mime type of the file? // if so, get the type of the mime from that function (more secure) // otherwise, use the one from the browser - // as of php 5.3 mime_content_type is deprecated, use finfo_open instead - if (function_exists('finfo_open')) + // as of php 5.3 mime_content_type is deprecated, use finfo instead + // (the object is freed by itself, finfo_close() is deprecated as of php 8.5) + if (class_exists('finfo')) { - $finfo = finfo_open(FILEINFO_MIME); - $sTypeRaw = finfo_file($finfo, $aFile['tmp_name']); - finfo_close($finfo); + $finfo = new finfo(FILEINFO_MIME); + $sTypeRaw = $finfo->file($aFile['tmp_name']); list($sType) = preg_split('/;/', $sTypeRaw); } else From ae857a6052d3ee8d2b5cf8df94a8f98b13c9bb46 Mon Sep 17 00:00:00 2001 From: tombrain Date: Sun, 1 Nov 2026 14:07:21 +0100 Subject: [PATCH 2/3] ci: PHPUnit on PHP 8.5, the latest dependencies on 8.5 --- .github/workflows/phpunit.yml | 4 ++-- CHANGELOG.md | 5 +++++ SETUP.md | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index ab400e8..06a3e10 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -13,12 +13,12 @@ jobs: # report every PHP version, not only the first failing one fail-fast: false matrix: - php: ['8.2', '8.3', '8.4'] + php: ['8.2', '8.3', '8.4', '8.5'] deps: ['locked'] include: # composer.lock is resolved for PHP 8.2; projects on a newer PHP get newer # dependencies (e.g. symfony/html-sanitizer 8), so test them as well - - php: '8.4' + - php: '8.5' deps: 'latest' steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 69024c7..5a9dd6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ and the project follows [Semantic Versioning](https://semver.org/). - `UploadField` uses `finfo` as an object to get the mime type of the file. `finfo_close()` is deprecated as of PHP 8.5, so every upload with a type check gave a deprecation notice. +### Changed + +- GitHub Actions runs the tests on PHP 8.5 too, and the job with the latest dependencies + on PHP 8.5 instead of 8.4. + ## [4.8.0] - 2026-11-01 ### Added diff --git a/SETUP.md b/SETUP.md index 496081e..9e1e2ea 100644 --- a/SETUP.md +++ b/SETUP.md @@ -1,7 +1,7 @@ # FormHandler – Development setup FormHandler is developed and tested with **PHP 8.2 in a Docker container**. You do -not need a local PHP installation. GitHub Actions runs the tests on PHP 8.2, 8.3 and 8.4. +not need a local PHP installation. GitHub Actions runs the tests on PHP 8.2, 8.3, 8.4 and 8.5. ## Requirements @@ -82,7 +82,7 @@ Then open . Another port: `FH_WEB_PORT=8090 doc | Workflow | File | Runs | |---|---|---| -| PHPUnit | `.github/workflows/phpunit.yml` | tests with coverage on PHP 8.2, 8.3 and 8.4 | +| PHPUnit | `.github/workflows/phpunit.yml` | tests with coverage on PHP 8.2, 8.3, 8.4 and 8.5 | | PHPStan | `.github/workflows/phpstan.yml` | static analysis on PHP 8.2 | | Examples | `.github/workflows/examples.yml` | requests every example page on the PHP built-in server | From d404ecdd7f835d1d956b1d68f3a2d96a0277f270 Mon Sep 17 00:00:00 2001 From: tombrain Date: Sun, 1 Nov 2026 17:19:41 +0100 Subject: [PATCH 3/3] fix: ImageConverter frees its images with unset(), imagedestroy() is deprecated in PHP 8.5 --- CHANGELOG.md | 3 +++ src/includes/class.ImageConverter.php | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a9dd6c..9c58179 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ and the project follows [Semantic Versioning](https://semver.org/). - `UploadField` uses `finfo` as an object to get the mime type of the file. `finfo_close()` is deprecated as of PHP 8.5, so every upload with a type check gave a deprecation notice. +- `ImageConverter` (`resizeImage()`, `mergeImage()`) frees its images with `unset()`. + `imagedestroy()` is deprecated as of PHP 8.5; it has no effect since PHP 8.0, when GD + images became objects. ### Changed diff --git a/src/includes/class.ImageConverter.php b/src/includes/class.ImageConverter.php index aaed1ce..35c333b 100644 --- a/src/includes/class.ImageConverter.php +++ b/src/includes/class.ImageConverter.php @@ -185,9 +185,9 @@ public function doResize($sDestination, $iNewWidth, $iNewHeight) $this->_aSize[1] = $iNewHeight; } - // clean up - ImageDestroy($rOrg); - ImageDestroy($rImgResized); + // clean up (GD images are objects since php 8.0, imagedestroy() is deprecated as of php 8.5) + unset($rOrg); + unset($rImgResized); } } @@ -251,7 +251,7 @@ public function doMerge($sStamp, $sAlign, $sValign, $aTransparant = null) // Copy the current file to the new one ImageCopy($rImgDest, $rImgSrc, 0, 0, 0, 0, $this->_aSize[0], $this->_aSize[1]); - ImageDestroy($rImgSrc); + unset($rImgSrc); // get the new position for the stamp $x = ImageSX($rImgStamp); @@ -264,11 +264,11 @@ public function doMerge($sStamp, $sAlign, $sValign, $aTransparant = null) //ImageCopy( $rImgDest, $rImgStamp, $posX, $posY, 0, 0, $x, $y ); # transparant isnt working! //ImageCopyResampled( $rImgDest, $rImgStamp, 0, 0, $x, $y, $x, $y ); # transparant isnt working! - ImageDestroy($rImgStamp); + unset($rImgStamp); // Save the new image $this->_saveImage($rImgDest, $this->_sImage, 100); - ImageDestroy($rImgDest); + unset($rImgDest); } else {