diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 640897ea16..6424becaa7 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -23,6 +23,7 @@ Yii Framework 2 Change Log - Bug #18898: Fix `yii\helpers\Inflector::camel2words()` to work with words ending with 0 (michaelarnauts) - Enh #18904: Improve Captcha client-side validation (hexkir) - Bug #18913: Add filename validation for `MessageSource::getMessageFilePath()` (uaoleg) +- Bug #18909: Fix bug with binding default action parameters for controllers (bizley) 2.0.43 August 09, 2021 diff --git a/framework/base/Controller.php b/framework/base/Controller.php index 8ea901c37b..0c79060cef 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -563,10 +563,6 @@ class Controller extends Component implements ViewContextInterface */ final protected function bindInjectedParams(\ReflectionType $type, $name, &$args, &$requestedParams) { - if (!$type instanceof \ReflectionNamedType || $type->isBuiltin()) { - return; - } - // Since it is not a builtin type it must be DI injection. $typeName = $type->getName(); if (($component = $this->module->get($name, false)) instanceof $typeName) { diff --git a/framework/console/Controller.php b/framework/console/Controller.php index 57a6635474..6fb573db94 100644 --- a/framework/console/Controller.php +++ b/framework/console/Controller.php @@ -226,7 +226,12 @@ class Controller extends \yii\base\Controller } $args[] = $actionParams[$key] = $params[$key]; unset($params[$key]); - } elseif (PHP_VERSION_ID >= 70100 && ($type = $param->getType()) !== null) { + } elseif ( + PHP_VERSION_ID >= 70100 + && ($type = $param->getType()) !== null + && $type instanceof \ReflectionNamedType + && !$type->isBuiltin() + ) { try { $this->bindInjectedParams($type, $name, $args, $requestedParams); } catch (\yii\base\Exception $e) { diff --git a/framework/web/Controller.php b/framework/web/Controller.php index 5eac7ee534..2913e1993e 100644 --- a/framework/web/Controller.php +++ b/framework/web/Controller.php @@ -177,7 +177,12 @@ class Controller extends \yii\base\Controller } $args[] = $actionParams[$name] = $params[$name]; unset($params[$name]); - } elseif (PHP_VERSION_ID >= 70100 && ($type = $param->getType()) !== null) { + } elseif ( + PHP_VERSION_ID >= 70100 + && ($type = $param->getType()) !== null + && $type instanceof \ReflectionNamedType + && !$type->isBuiltin() + ) { try { $this->bindInjectedParams($type, $name, $args, $requestedParams); } catch (HttpException $e) {