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.3] Fix gatherMiddleware() only unique #16185

Merged
merged 1 commit into from
Oct 30, 2016
Merged

[5.3] Fix gatherMiddleware() only unique #16185

merged 1 commit into from
Oct 30, 2016

Conversation

actionm
Copy link
Contributor

@actionm actionm commented Oct 30, 2016

For example:

I have a route group with middleware 'auth' and controller with middleware 'auth'.

Maybe framework/src/Illuminate/Routing/Route.php gatherMiddleware() must return only unique values ?

class MainController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth');
    }
}


Route::group(['middleware' => ['auth']], function () {

    Route::get('/first', 'MainController@index');
}

Route::get('/second', 'MainController@index');

php artisan route:list

before:

| Domain | Method   | URI    | Name  | Action                                      | Middleware |

|        | GET|HEAD | first  |       | App\Http\Controllers\MainController@index   | web,auth,auth
|        | GET|HEAD | second |       | App\Http\Controllers\MainController@index   | web,auth

after fix:

| Domain | Method   | URI    | Name  | Action                                      | Middleware |

|        | GET|HEAD | first  |       | App\Http\Controllers\MainController@index   | web,auth
|        | GET|HEAD | second |       | App\Http\Controllers\MainController@index   | web,auth

Would it be more preferable if artisan route:list displayed middleware from route and controller separately?

For example:

| Domain | Method   | URI    | Name  | Action                                      | Middleware |

|        | GET|HEAD | first  |       | App\Http\Controllers\MainController@index   | [r]web,auth [c]auth
|        | GET|HEAD | second |       | App\Http\Controllers\MainController@index   | [r]web [c]auth

@actionm
Copy link
Contributor Author

actionm commented Oct 30, 2016

fixed branch to 5.3 from #16173

@taylorotwell taylorotwell merged commit 778a381 into laravel:5.3 Oct 30, 2016
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.

None yet

2 participants