Browse Source

Fix yii\base\Controller::bindInjectedParams() to not throw error when argument of `ReflectionUnionType` type is passed (#18869)

tags/2.0.44
Bizley 3 years ago committed by GitHub
parent
commit
ea60fba0ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      framework/CHANGELOG.md
  2. 4
      framework/base/Controller.php
  3. 2
      framework/console/Controller.php
  4. 2
      framework/web/Controller.php

1
framework/CHANGELOG.md

@ -14,6 +14,7 @@ Yii Framework 2 Change Log
- Enh #18783: Add `XmlResponseFormatter::$objectTagToLowercase` option to lowercase object tags (WinterSilence, samdark)
- Bug #18845: Fix duplicating `id` in `MigrateController::addDefaultPrimaryKey()` (WinterSilence, samdark)
- Bug #17119: Fix `yii\caching\Cache::multiSet()` to use `yii\caching\Cache::$defaultDuration` when no duration is passed (OscarBarrett)
- Bug #18842: Fix `yii\base\Controller::bindInjectedParams()` to not throw error when argument of `ReflectionUnionType` type is passed (bizley)
2.0.43 August 09, 2021

4
framework/base/Controller.php

@ -563,6 +563,10 @@ 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) {

2
framework/console/Controller.php

@ -226,7 +226,7 @@ class Controller extends \yii\base\Controller
}
$args[] = $actionParams[$key] = $params[$key];
unset($params[$key]);
} elseif (PHP_VERSION_ID >= 70100 && ($type = $param->getType()) !== null && !$type->isBuiltin()) {
} elseif (PHP_VERSION_ID >= 70100 && ($type = $param->getType()) !== null) {
try {
$this->bindInjectedParams($type, $name, $args, $requestedParams);
} catch (\yii\base\Exception $e) {

2
framework/web/Controller.php

@ -177,7 +177,7 @@ class Controller extends \yii\base\Controller
}
$args[] = $actionParams[$name] = $params[$name];
unset($params[$name]);
} elseif (PHP_VERSION_ID >= 70100 && ($type = $param->getType()) !== null && !$type->isBuiltin()) {
} elseif (PHP_VERSION_ID >= 70100 && ($type = $param->getType()) !== null) {
try {
$this->bindInjectedParams($type, $name, $args, $requestedParams);
} catch (HttpException $e) {

Loading…
Cancel
Save