From c50e2d17498775bb79e89b960ec5346cb3b990ca Mon Sep 17 00:00:00 2001 From: Dmitry Eliseev Date: Tue, 9 Dec 2025 19:34:01 +0300 Subject: [PATCH] Fix #20689: Fix PHP `8.5` `imagedestroy` deprecation warning --- framework/CHANGELOG.md | 1 + framework/captcha/CaptchaAction.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 4a1f9c27b6..166d64fcfe 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -84,6 +84,7 @@ Yii Framework 2 Change Log - Bug #20673: Sanitize `null` bytes before `quoteValue()` on PHP 8.5+ in SQLite (terabytesoftw) - Bug #20671: Fix PHPDoc annotations in `yii\base`, `yii\console`, `yii\web` and `yii\widgets` namespaces (mspirkov) - Bug #20675: Add generics for all controllers (mspirkov) +- Bug #20689: Fix PHP `8.5` `imagedestroy` deprecation warning (ElisDN) 2.0.53 June 27, 2025 diff --git a/framework/captcha/CaptchaAction.php b/framework/captcha/CaptchaAction.php index 11e9391a23..53ebc87b8a 100644 --- a/framework/captcha/CaptchaAction.php +++ b/framework/captcha/CaptchaAction.php @@ -314,7 +314,11 @@ class CaptchaAction extends Action ob_start(); imagepng($image); - imagedestroy($image); + + // Function `imagedestroy` is deprecated since PHP `8.5`, as it has no effect since PHP `8.0` + if (PHP_VERSION_ID < 80000) { + imagedestroy($image); + } return ob_get_clean(); }