Skip to content

[BrowserKit] BC-Break with casting parameters to string #38651

@michaljusiega

Description

@michaljusiega

Symfony version(s) affected: 5.2.0-BETA2

Description
My CI/CD tests are crazy after upgrade to Symfony 5.2.0-BETA2. So...
All parameters as null value are casting to string. So (string) null is '' (empty string).

How to reproduce

$browserClient = self::createClient();
$browserClient->request(Request::METHOD_GET, '/url', ['string_value' => 'string', 'nullable_value' => null]);
/** @var \Symfony\Component\HttpFoundation\Request $request */
dd($request->query->all());

In Symfony 5.2-BETA2:

array:2 [
  "string_value" => "string"
  "nullable_value" => ""
]

In Symfony 5.1 and lower:

array:2 [
  "string_value" => "string"
  "nullable_value" => null
]

Possible Solution
Workaround and ignore nullable values:

        array_walk_recursive($parameters, static function (&$value) {
            $value = (string) $value;
        });

to:

        array_walk_recursive($parameters, static function (&$value) {
            if (null !== $value) {
                $value = (string) $value;
            }
        });

Additional context
See #37740 and #37755

I'm ready to make PR.

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy