Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0] Fix Broken File Upload When Submitting A Form Without Selecting A File #6256

Merged
merged 10 commits into from
Nov 20, 2014
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)
);
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just ?

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

* {@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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put two blank lines between test methods.

{
$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);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.


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