Skip to content

[9.x] Add failing tests $request->query() no longer can retrieve array query string#40599

Closed
crynobone wants to merge 2 commits intolaravel:9.xfrom
crynobone:query-with-array
Closed

[9.x] Add failing tests $request->query() no longer can retrieve array query string#40599
crynobone wants to merge 2 commits intolaravel:9.xfrom
crynobone:query-with-array

Conversation

@crynobone
Copy link
Member

@crynobone crynobone commented Jan 25, 2022

Exact same code from #40598 for Laravel 9

1) Illuminate\Tests\Http\HttpRequestTest::testQueryMethod
Symfony\Component\HttpFoundation\Exception\BadRequestException: Input value "user" contains a non-scalar value.

/home/runner/work/framework/framework/vendor/symfony/http-foundation/InputBag.php:37
/home/runner/work/framework/framework/src/Illuminate/Http/Concerns/InteractsWithInput.php:510
/home/runner/work/framework/framework/src/Illuminate/Http/Concerns/InteractsWithInput.php:383
/home/runner/work/framework/framework/tests/Http/HttpRequestTest.php:681

Signed-off-by: Mior Muhammad Zaki crynobone@gmail.com

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
@X-Coder264
Copy link
Contributor

This is due to the following deprecation https://github.com/symfony/symfony/blob/v5.4.2/src/Symfony/Component/HttpFoundation/InputBag.php#L39 (which was added via symfony/symfony#34363)

In order for array parameters to work with Symfony 6 \Illuminate\Http\Concerns\InteractsWithInput::retrieveItem will have to be adjusted from

        if (is_null($key)) {
            return $this->$source->all();
        }

        return $this->$source->get($key, $default);

to

        if (is_null($key)) {
            return $this->$source->all();
        }

        return $this->$source->all()[$key] ?? $default;

@crynobone
Copy link
Member Author

crynobone commented Jan 25, 2022

@X-Coder264 feel free to create a PR. Mine is more just to verify there is a bug and the other test PR to 8.x will be merged to 9.x eventually.

@X-Coder264
Copy link
Contributor

@crynobone Done -> #40609

@crynobone crynobone closed this Jan 25, 2022
@crynobone crynobone deleted the query-with-array branch November 3, 2022 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants