Fix #19322: Revert force setting value to empty string in case it's null in yii\validators\FilterValidator::validateAttribute()

This commit is contained in:
Bizley
2022-03-24 14:50:00 +01:00
committed by GitHub
parent 7cc45f75f5
commit 2874e070f3
3 changed files with 4 additions and 2 deletions

View File

@ -9,6 +9,7 @@ Yii Framework 2 Change Log
- Bug #19291: Reset errors and validators in `yii\base\Model::__clone()` (WinterSilence)
- Enh #19304: Add filtering validator `yii\validators\TrimValidator` (WinterSilence)
- Enh #19309: Optimize `yii\base\Model::attributes()` (WinterSilence)
- Bug #19322: Revert force setting value to empty string in case it's `null` in `yii\validators\FilterValidator::validateAttribute()` (bizley)
2.0.45 February 11, 2022

View File

@ -25,6 +25,8 @@ use yii\base\InvalidConfigException;
* ```
*
* Many PHP functions qualify this signature (e.g. `trim()`).
* If the callback function requires non-null argument (important since PHP 8.1)
* remember to set [[skipOnEmpty]] to `true` otherwise you may trigger an error.
*
* To specify the filter, set [[filter]] property to be the callback.
*
@ -75,7 +77,6 @@ class FilterValidator extends Validator
{
$value = $model->$attribute;
if (!$this->skipOnArray || !is_array($value)) {
$value = isset($value) ? $value : '';
$model->$attribute = call_user_func($this->filter, $value);
}
}