File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ Yii Framework 2 Change Log
26
26
- Bug #19237 : Fix OCI PHP 8.1 passing ` null ` to trim() (longthanhtran)
27
27
- Bug #19312 : Fix PHP 8.1 error when passing null to ` yii\helpers\BaseInflector ` (WinterSilence)
28
28
- Bug #19368 : Fix PHP 8.1 error when ` $fileMimeType ` is ` null ` in ` yii\validators\FileValidator::validateMimeType() ` (bizley)
29
+ - Enh #19384 : Normalize ` setBodyParams() ` and ` getBodyParam() ` in ` yii\web\Request ` (WinterSilence, albertborsos)
29
30
- Bug #19386 : Fix recursive calling ` yii\helpers\BaseArrayHelper::htmlDecode() ` (WinterSilence)
30
31
31
32
Original file line number Diff line number Diff line change @@ -597,8 +597,8 @@ public function getBodyParams()
597
597
598
598
/**
599
599
* Sets the request body parameters.
600
- * @param array $values the request body parameters (name-value pairs)
601
- * @see getBodyParam( )
600
+ *
601
+ * @param array|object $values the request body parameters (name-value pairs )
602
602
* @see getBodyParams()
603
603
*/
604
604
public function setBodyParams ($ values )
@@ -608,7 +608,9 @@ public function setBodyParams($values)
608
608
609
609
/**
610
610
* Returns the named request body parameter value.
611
+ *
611
612
* If the parameter does not exist, the second parameter passed to this method will be returned.
613
+ *
612
614
* @param string $name the parameter name
613
615
* @param mixed $defaultValue the default parameter value if the parameter does not exist.
614
616
* @return mixed the parameter value
@@ -622,7 +624,7 @@ public function getBodyParam($name, $defaultValue = null)
622
624
if (is_object ($ params )) {
623
625
// unable to use `ArrayHelper::getValue()` due to different dots in key logic and lack of exception handling
624
626
try {
625
- return $ params ->{$ name };
627
+ return isset ( $ params ->{$ name }) ? $ params ->{ $ name } : $ defaultValue ;
626
628
} catch (\Exception $ e ) {
627
629
return $ defaultValue ;
628
630
}
You can’t perform that action at this time.
0 commit comments