Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use request set in crud instead of global request instance #4823

Merged
merged 5 commits into from
Dec 8, 2022

Conversation

pxpm
Copy link
Contributor

@pxpm pxpm commented Dec 7, 2022

WHY

BEFORE - What was wrong? What was happening before this PR?

I think this was a leftover from some old refactoring since we are already using the request defined in the CrudPanel in other methods, eg:

$input = $input ?? new ParameterBag($this->crud()->getRequest()->all());

AFTER - What is happening after this PR?

I replaced the global request instances for the requests defined in CrudPanel, in the end it would fallback to the global request instance in case a request is not set in CrudPanel.

Is it a breaking change?

I don't think so no.

How can we test the before & after?

This is testable if you are manually creating a request instance and attaching it to the CrudPanel.

        $request = request()->create('/admin/users', 'GET', ['my_custom_filter' => 'foo']);
        $request->setRouteResolver(function () use ($request) {
            return (new Route('GET', 'admin/users', ['UserCrudController', 'index']))->bind($request);
        });
        $this->crudPanel->setRequest($request);

The global \Request instance has no access to this Request that we set on the CrudPanel.

@pxpm pxpm added Minor Bug A bug that happens only in a very niche or specific use case. Priority: MUST labels Dec 7, 2022
@scrutinizer-notifier
Copy link

The inspection completed: No new issues

@tabacitu tabacitu merged commit 8f7686f into main Dec 8, 2022
@tabacitu tabacitu deleted the use-crud-request branch December 8, 2022 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Minor Bug A bug that happens only in a very niche or specific use case. Priority: MUST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants