From 22889d314ab4ea20df00e594d4ef7fb09fa55f5a Mon Sep 17 00:00:00 2001 From: Wilmer Arambula <42547589+terabytesoftw@users.noreply.github.com> Date: Wed, 20 Aug 2025 14:45:49 -0400 Subject: [PATCH] Fix #20492: Fix deprecation of `finfo_close()` in PHP `8.5` by conditionally closing the resource --- framework/CHANGELOG.md | 1 + framework/helpers/BaseFileHelper.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 71afa45fb2..48339bb37f 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -16,6 +16,7 @@ Yii Framework 2 Change Log - Bug #20482: Fix deprecation of `ReflectionMethod::setAccessible()` in PHP `8.5` (terabytesoftw) - Enh #20480: Add PHPStan/Psalm annotations for `ServiceLocator::get` (max-s-lab) - Bug #20447: Fix behavior for `yii\web\Controller::bindActionParams` around `mixed` type (chriscpty) +- Bug #20492: Fix deprecation of `finfo_close()` in PHP `8.5` by conditionally closing the resource (terabytesoftw) 2.0.53 June 27, 2025 -------------------- diff --git a/framework/helpers/BaseFileHelper.php b/framework/helpers/BaseFileHelper.php index 55445aec00..8ec2761dae 100644 --- a/framework/helpers/BaseFileHelper.php +++ b/framework/helpers/BaseFileHelper.php @@ -171,7 +171,11 @@ class BaseFileHelper if ($info) { $result = finfo_file($info, $file); - finfo_close($info); + // @link https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_finfo_close + // @link https://github.com/php/php-src/commit/ccb716dcadf60d989db48e4d2963e14d7dc63df3 + if (PHP_VERSION_ID < 80500) { + finfo_close($info); + } if ($result !== false) { return $result;