From de2e5ea58ca1d803e87497efb70b32abeb703574 Mon Sep 17 00:00:00 2001 From: Tim Kelty Date: Thu, 18 Jul 2024 15:44:00 -0400 Subject: [PATCH] Fix #20230: Fix getting ID in `\yii\filters\Cors::actions()` when attached to a module --- framework/CHANGELOG.md | 1 + framework/filters/Cors.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index fda96ccd2cd..7dca0fb1296 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -10,6 +10,7 @@ Yii Framework 2 Change Log - Bug #20211: Add acceptable parameters to `MaskedInput::init()` method (alxlnk) - Bug #20226: Revert all PR for "Data providers perform unnecessary COUNT queries that negatively affect performance" (@terabytesoftw) - Bug #20147: Fix error handler compatibility with PHP 8.3 (samdark) +- Bug #20230: Fix getting ID in `\yii\filters\Cors::actions()` when attached to a module (timkelty) 2.0.50 May 30, 2024 diff --git a/framework/filters/Cors.php b/framework/filters/Cors.php index b6b99a79bfc..c377dcb0994 100644 --- a/framework/filters/Cors.php +++ b/framework/filters/Cors.php @@ -123,8 +123,10 @@ public function beforeAction($action) */ public function overrideDefaultSettings($action) { - if (isset($this->actions[$action->id])) { - $actionParams = $this->actions[$action->id]; + $actionId = $this->getActionId($action); + + if (isset($this->actions[$actionId])) { + $actionParams = $this->actions[$actionId]; $actionParamsKeys = array_keys($actionParams); foreach ($this->cors as $headerField => $headerValue) { if (in_array($headerField, $actionParamsKeys)) {