Browse Source

Fix #18909: Fix bug with binding default action parameters for controllers

tags/2.0.44
Bizley 3 years ago committed by GitHub
parent
commit
ae82b58d85
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. 7
      framework/console/Controller.php
  4. 7
      framework/web/Controller.php

1
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) - Bug #18898: Fix `yii\helpers\Inflector::camel2words()` to work with words ending with 0 (michaelarnauts)
- Enh #18904: Improve Captcha client-side validation (hexkir) - Enh #18904: Improve Captcha client-side validation (hexkir)
- Bug #18913: Add filename validation for `MessageSource::getMessageFilePath()` (uaoleg) - 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 2.0.43 August 09, 2021

4
framework/base/Controller.php

@ -563,10 +563,6 @@ class Controller extends Component implements ViewContextInterface
*/ */
final protected function bindInjectedParams(\ReflectionType $type, $name, &$args, &$requestedParams) 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. // Since it is not a builtin type it must be DI injection.
$typeName = $type->getName(); $typeName = $type->getName();
if (($component = $this->module->get($name, false)) instanceof $typeName) { if (($component = $this->module->get($name, false)) instanceof $typeName) {

7
framework/console/Controller.php

@ -226,7 +226,12 @@ class Controller extends \yii\base\Controller
} }
$args[] = $actionParams[$key] = $params[$key]; $args[] = $actionParams[$key] = $params[$key];
unset($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 { try {
$this->bindInjectedParams($type, $name, $args, $requestedParams); $this->bindInjectedParams($type, $name, $args, $requestedParams);
} catch (\yii\base\Exception $e) { } catch (\yii\base\Exception $e) {

7
framework/web/Controller.php

@ -177,7 +177,12 @@ class Controller extends \yii\base\Controller
} }
$args[] = $actionParams[$name] = $params[$name]; $args[] = $actionParams[$name] = $params[$name];
unset($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 { try {
$this->bindInjectedParams($type, $name, $args, $requestedParams); $this->bindInjectedParams($type, $name, $args, $requestedParams);
} catch (HttpException $e) { } catch (HttpException $e) {

Loading…
Cancel
Save