laravel-responder
laravel-responder copied to clipboard
Setting config `filter_fields_parameter` to null doesn't disable query string fieldset filtering
Responder version: 3.0.5 Laravel version: v5.5.45
In the config file, the documentation for filter_fields_parameter says:
The package can automatically filter the fields of transformed data from a query string parameter configured below. The technique is also known as sparse fieldsets. Set it to null to disable it.
However, when setting it to null I started getting Array to string conversion errors when I sent any query parameters.
I think the cause is here:
$this->app->bind(TransformBuilder::class, function ($app) {
$request = $this->app->make(Request::class);
$relations = $request->input($this->app->config['responder.load_relations_parameter'], []);
$fieldsets = $request->input($app->config['responder.filter_fields_parameter'], []);
return (new TransformBuilder($app->make(ResourceFactoryContract::class), $app->make(TransformFactoryContract::class), $app->make(PaginatorFactoryContract::class)))->serializer($app->make(SerializerAbstract::class))
->with(is_string($relations) ? explode(',', $relations) : $relations)
->only($fieldsets);
});
I've set a xdebug breakpoint after the fieldsets and relations are parsed, and apparently sending null as the key returns the whole request input, as opposed to what I assume was the intended effect of an empty array.
Here is a screenshot of the debugger. What you see in the $fieldsets array is essentially the whole parsed query string:

I can fix this in my project by overriding that method in the service provider, but it still seems like a bug.
Hey! This does indeed seem like an error. I'll look into it, thanks