Skip to content

Commit 22889d3

Browse files
Fix #20492: Fix deprecation of finfo_close() in PHP 8.5 by conditionally closing the resource
1 parent f5a071b commit 22889d3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

framework/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Yii Framework 2 Change Log
1616
- Bug #20482: Fix deprecation of `ReflectionMethod::setAccessible()` in PHP `8.5` (terabytesoftw)
1717
- Enh #20480: Add PHPStan/Psalm annotations for `ServiceLocator::get` (max-s-lab)
1818
- Bug #20447: Fix behavior for `yii\web\Controller::bindActionParams` around `mixed` type (chriscpty)
19+
- Bug #20492: Fix deprecation of `finfo_close()` in PHP `8.5` by conditionally closing the resource (terabytesoftw)
1920

2021
2.0.53 June 27, 2025
2122
--------------------

framework/helpers/BaseFileHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ public static function getMimeType($file, $magicFile = null, $checkExtension = t
171171

172172
if ($info) {
173173
$result = finfo_file($info, $file);
174-
finfo_close($info);
174+
// @link https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_finfo_close
175+
// @link https://github.com/php/php-src/commit/ccb716dcadf60d989db48e4d2963e14d7dc63df3
176+
if (PHP_VERSION_ID < 80500) {
177+
finfo_close($info);
178+
}
175179

176180
if ($result !== false) {
177181
return $result;

0 commit comments

Comments
 (0)