8000 UploadedFile deprecation notice with empty files · Issue #31515 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
UploadedFile deprecation notice with empty files #31515
Closed
@cs278

Description

@cs278

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

      0