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

[5.8] Fix guessed policy names when using Gate::forUser #27708

merged 2 commits into from Feb 28, 2019


None yet
3 participants
Copy link

erikgaal commented Feb 28, 2019


When using the Gate facade to create a new instance for a specific user with forUser the guessPolicyNameUsingCallback is not passed on to the new instance. This results in the policies no policies being loaded when using just the policy name guesser.


Gate::guessPolicyNamesUsing(function ($class) {
    return 'foo';

// #guessPolicyNamesUsingCallback: Closure($class) {#371

// #guessPolicyNamesUsingCallback: null

Proposed Solution

Add the guessPolicyNameUsingCallback nullable argument to the constructor and pass it in the forUser method.


This comment has been minimized.

Copy link
Contributor Author

erikgaal commented Feb 28, 2019

This probably needs a test so it won't break again.

@erikgaal erikgaal changed the title [5.8] Make Gate::forUser pass the policy guesser to the constructor [5.8] Fix guessed policy names when using Gate::forUser Feb 28, 2019

@taylorotwell taylorotwell merged commit c56c597 into laravel:5.8 Feb 28, 2019

2 checks passed

continuous-integration/styleci/pr The analysis has passed
continuous-integration/travis-ci/pr The Travis CI build passed

@erikgaal erikgaal deleted the erikgaal:5.8-gate-for-user-policy-guesser branch Feb 28, 2019


This comment has been minimized.

Copy link

TBlindaruk commented Mar 3, 2019

@erikgaal #27757 I have created issue for the test

taylorotwell added a commit that referenced this pull request Mar 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.