Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Request::create can trigger deprecated array conversion in 8.1 with bad values #47084

Closed
@neclimdul

Description

@neclimdul

Symfony version(s) affected

<=6.2

Description

If you provide a bad value to Request::create, its possible parse_url will fail to parse it settings $components to false. Later code doesn't handle the false condition which "works" because the last bit assigns a value to the variable converting it to an array. In PHP 8.1+ however this conversion behavior is deprecated.

How to reproduce

Request::create('/foo:123');

Outputs something like:

Deprecated function: Automatic conversion of false to array is deprecated in Symfony\Component\HttpFoundation\Request::create() (line 372 of /app/vendor/symfony/http-foundation/Request.php).
Symfony\Component\HttpFoundation\Request::create('/foo:123') ....

Possible Solution

The url isn't valid so it would probably be good to provide developer feedback but throwing an exception would be pretty disruptive.

Seems like the best approach might be:

  1. Explicitly handle the false condition preserving the current behavior. Include deprecation.
  2. Throw a InvalidArgument exception or similar in some future version.

Additional Context

No response

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