Browse Source

Fixes #1412

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
807223efbf
  1. 2
      framework/CHANGELOG.md
  2. 2
      framework/validators/FileValidator.php
  3. 8
      framework/validators/ImageValidator.php

2
framework/CHANGELOG.md

@ -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)

2
framework/validators/FileValidator.php

@ -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:

8
framework/validators/ImageValidator.php

@ -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;
}
}
/**

Loading…
Cancel
Save