Fix #18756: Fix \yii\validators\ExistValidator::queryValueExists to validate against an array of unique values

This commit is contained in:
DrDeath72
2021-08-04 23:00:58 +05:00
committed by GitHub
parent ca50dd0bc7
commit be1b98b1df
3 changed files with 9 additions and 1 deletions

View File

@ -19,6 +19,7 @@ Yii Framework 2 Change Log
- Bug #18648: Fix `yii\web\Request` to properly handle HTTP Basic Auth headers (olegbaturin)
- Enh #18726: Added `yii\helpers\Json::$prettyPrint` (rhertogh)
- Enh #18734: Added `yii\validators\EmailValidator::$enableLocalIDN` (brandonkelly)
- Bug #18756: Fix `\yii\validators\ExistValidator::queryValueExists` to validate against an array of unique values (DrDeath72)
- Enh #18656: Added ability for `yii serve`'s `--router` param to take an alias (markhuot)
- Bug #18274: Fix `yii\log\Logger` to calculate profile timings no matter the value of the flush interval (bizley)

View File

@ -280,7 +280,7 @@ class ExistValidator extends Validator
private function queryValueExists($query, $value)
{
if (is_array($value)) {
return $query->count("DISTINCT [[$this->targetAttribute]]") == count($value) ;
return $query->count("DISTINCT [[$this->targetAttribute]]") == count(array_unique($value)) ;
}
return $query->exists();
}