Commit 807223ef by Qiang Xue

Fixes #1412

parent 22fa0d7c
......@@ -6,7 +6,7 @@ Yii Framework 2 Change Log
- Bug #1265: AssetController does not override 'js' and 'css' for compressed bundles (klimov-paul)
- Bug #1326: The `visible` setting for `DetailView` doesn't work as expected (qiangxue)
- Bug #1412: `FileValidator` still triggers `uploadRequired` error in some case when `skipOnEmpty` is true and no upload is provided (qiangxue)
- Bug #1412: `FileValidator` and `ImageValidator` still trigger `uploadRequired` error in some case when `skipOnEmpty` is true and no upload is provided (qiangxue)
- Bug #1446: Logging while logs are processed causes infinite loop (qiangxue)
- Bug #1497: Localized view files are not correctly returned (mintao)
- Bug #1500: Log messages exported to files are not separated by newlines (omnilight, qiangxue)
......
......@@ -167,7 +167,7 @@ class FileValidator extends Validator
protected function validateValue($file)
{
if (!$file instanceof UploadedFile || $file->error == UPLOAD_ERR_NO_FILE) {
return $this->skipOnEmpty ? [] : [$this->uploadRequired, []];
return $this->skipOnEmpty ? null : [$this->uploadRequired, []];
}
switch ($file->error) {
case UPLOAD_ERR_OK:
......
......@@ -144,8 +144,12 @@ class ImageValidator extends FileValidator
*/
protected function validateValue($file)
{
$result = parent::validateValue($file);
return empty($result) ? $this->validateImage($file) : $result;
if ($this->skipOnEmpty && (!$file instanceof UploadedFile || $file->error == UPLOAD_ERR_NO_FILE)) {
return null;
} else {
$result = parent::validateValue($file);
return empty($result) ? $this->validateImage($file) : $result;
}
}
/**
......
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