Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

UploadedFile deprecation notice with empty files #31515

Copy link
Copy link
Closed
@cs278

Description

@cs278
Issue body actions

Symfony version(s) affected: Probably >= 4.1.0, reproduced on 4.2.7

Description

If you have a file upload form and a user uploads a zero byte file, Symfony raises a deprecation notice.

Passing a size as 4th argument to the constructor of "Symfony\Component\HttpFoundation\File\UploadedFile" is deprecated since Symfony 4.1.

The root cause is line 68.

if (4 < \func_num_args() ? !\is_bool($test) : null !== $error && @filesize($path) === $error) {
@trigger_error(sprintf('Passing a size as 4th argument to the constructor of "%s" is deprecated since Symfony 4.1.', __CLASS__), E_USER_DEPRECATED);
$error = $test;
$test = 5 < \func_num_args() ? func_get_arg(5) : false;
}

How to reproduce

Use the Form component, add a FileType input and upload a 0 byte file, deprecation notice should be logged.

Possible Solution

Given that any file size of 0-8 bytes should cause the same issue (as the UPLOAD_ERR_ constants have that range of values), I'm not sure it can be fixed. Perhaps the best solution is to update the message to document this edge case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.