Skip to content

inputbag doesn't allow array's #44432

Closed
Closed
@dvdknaap

Description

@dvdknaap

Symfony version(s) affected

6.0

Description

This bug was already mentioned in #41766 (comment)

The issue is still not fixed and get a 'Message: Input value "fieldname" contains a non-scalar value.' error now.

The set function is accepting an error and even \Stringable but the accept doesn't have the same check and is inconsistent now.
get function - vendor/symfony/http-foundation/InputBag.php:36

        if (null !== $value && $this !== $value && !is_scalar($value)) {
            throw new BadRequestException(sprintf('Input value "%s" contains a non-scalar value.', $key));
        }

set function - vendor/symfony/http-foundation/InputBag.php:77

        if (null !== $value && !is_scalar($value) && !\is_array($value) && !$value instanceof \Stringable) {
            throw new \InvalidArgumentException(sprintf('Excepted a scalar, or an array as a 2nd argument to "%s()", "%s" given.', __METHOD__, get_debug_type($value)));
        }

How to reproduce

Set a array _GET or _POST value and try to get the same _GET or POST key

Possible Solution

Add the same check that's in the set function also in the get function

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