Skip to content

Commit

Permalink
Merge pull request #6256 from eduard44/master
Browse files Browse the repository at this point in the history
[5.0] Fix Broken File Upload When Submitting A Form Without Selecting A File
  • Loading branch information
taylorotwell committed Nov 20, 2014
2 parents cda27de + 20c508f commit 604ad07
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Illuminate/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,16 @@ public static function createFromBase(SymfonyRequest $request)
);
}

/**
* {@inheritdoc}
*/
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
{
$files = array_filter((array) $files);

return parent::duplicate($query, $request, $attributes, $cookies, $files, $server);
}

/**
* Get the session associated with the request.
*
Expand Down
19 changes: 19 additions & 0 deletions tests/Http/HttpRequestTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Mockery as m;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
use Illuminate\Http\Request;

class HttpRequestTest extends PHPUnit_Framework_TestCase {
Expand Down Expand Up @@ -349,6 +350,24 @@ public function testAllInputWithNumericKeysReturnsInputAfterReplace()
}


public function testInputWithEmptyFilename()
{
$invalidFiles = [
'file' => [
'name' => null,
'type' => null,
'tmp_name' => null,
'error' => 4,
'size' => 0
]
];

$baseRequest = SymfonyRequest::create('/?boom=breeze', 'GET', array('foo' => array('bar' => 'baz')), array(), $invalidFiles);

$request = Request::createFromBase($baseRequest);
}


public function testOldMethodCallsSession()
{
$request = Request::create('/', 'GET');
Expand Down

0 comments on commit 604ad07

Please sign in to comment.