diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index ab400e8f..06a3e103 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 2e8abc7a..9c581796 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ 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. +- `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 + +- 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 496081e6..9e1e2ea1 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 | diff --git a/src/fields/class.UploadField.php b/src/fields/class.UploadField.php index 6891ae6f..f266660a 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 diff --git a/src/includes/class.ImageConverter.php b/src/includes/class.ImageConverter.php index aaed1ce4..35c333bb 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 {