Commit b9b6fbc9 by Qiang Xue

Fixes #5039: `UniqueValidator` and `ExistValidator` did not respect query…

Fixes #5039: `UniqueValidator` and `ExistValidator` did not respect query conditions added by default scope
parent cebc2567
......@@ -94,6 +94,7 @@ Yii Framework 2 Change Log
- Bug #4954: MSSQL column comments are not retrieved correctly (SerjRamone)
- Bug #4970: `joinWith()` called by a relation was ignored by `yii\db\ActiveQuery` (stepanselyuk)
- Bug #5001: `yii\rest\CreateAction`, `yii\rest\UpdateAction` and `yii\rest\DeleteAction` should throw 500 error if the model operation returns false without validation errors (qiangxue)
- Bug #5039: `UniqueValidator` and `ExistValidator` did not respect query conditions added by default scope (qiangxue)
- Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark)
- Bug: URL encoding for the route parameter added to `\yii\web\UrlManager` (klimov-paul)
- Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue)
......
......@@ -152,7 +152,7 @@ class ExistValidator extends Validator
protected function createQuery($targetClass, $condition)
{
/* @var $targetClass \yii\db\ActiveRecordInterface */
$query = $targetClass::find()->where($condition);
$query = $targetClass::find()->andWhere($condition);
if ($this->filter instanceof \Closure) {
call_user_func($this->filter, $query);
} elseif ($this->filter !== null) {
......
......@@ -98,7 +98,7 @@ class UniqueValidator extends Validator
}
$query = $targetClass::find();
$query->where($params);
$query->andWhere($params);
if ($this->filter instanceof \Closure) {
call_user_func($this->filter, $query);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment