From 697a85dd262cc8fe6e7883d8ce230ab8a0fcfa55 Mon Sep 17 00:00:00 2001 From: OmgDef Date: Fri, 18 Jul 2014 21:36:29 +0400 Subject: [PATCH] Check for UPLOAD_ERR_NO_FILE in UploadedFile fixes #4276, close #4358 --- framework/CHANGELOG.md | 3 ++- framework/UPGRADE.md | 2 +- framework/web/UploadedFile.php | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 4f63f0313f..f849d1750f 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -66,6 +66,7 @@ Yii Framework 2 Change Log - Bug #4127: `CaptchaValidator` clientside error message wasn't formed properly (samdark) - Bug #4162: Fixed bug where schema name was not used in ’SHOW CREATE TABLE’ query in `yii\db\mysql\Schema` (stevekr) - Bug #4241: `yii\widgets\Pjax` was incorrectly setting container id (mitalcoi) +- Bug #4276: Added check for UPLOAD_ERR_NO_FILE in `yii\web\UploadedFile` and return null if no file was uploaded (OmgDef) - 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) @@ -188,7 +189,7 @@ Yii Framework 2 Change Log - Chg: Added `prefix` column to `yii\log\DbTarget` to have the same amount of information logged as in files and emails (cebe) - Chg: Use `limit(null)` instead of `limit(-1)` in migration controller to be compatible to more backends (cebe) - New #3911: Added `yii\behaviors\SluggableBehavior` that fills the specified model attribute with the transliterated and adjusted version to use in URLs (creocoder) -- New #4193: Added `yii\filters\Cors` CORS filter to allow Cross Origin Resource Sharing (pgaultier) +- New #4193: Added `yii\filters\Cors` CORS filter to allow Cross Origin Resource Sharing (pgaultier) 2.0.0-beta April 13, 2014 diff --git a/framework/UPGRADE.md b/framework/UPGRADE.md index 3bf8a4a152..e33f11e581 100644 --- a/framework/UPGRADE.md +++ b/framework/UPGRADE.md @@ -145,4 +145,4 @@ new ones save the following code as `convert.php` that should be placed in the s ], // ... ]; - ``` + ``` \ No newline at end of file diff --git a/framework/web/UploadedFile.php b/framework/web/UploadedFile.php index 60b26d29e3..9e00ec0d8d 100644 --- a/framework/web/UploadedFile.php +++ b/framework/web/UploadedFile.php @@ -223,7 +223,7 @@ class UploadedFile extends Object foreach ($names as $i => $name) { self::loadFilesRecursive($key . '[' . $i . ']', $name, $tempNames[$i], $types[$i], $sizes[$i], $errors[$i]); } - } else { + } elseif ($errors !== UPLOAD_ERR_NO_FILE) { self::$_files[$key] = new static([ 'name' => $names, 'tempName' => $tempNames, @@ -233,4 +233,4 @@ class UploadedFile extends Object ]); } } -} +} \ No newline at end of file