-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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.2] Apply middleware once even in nested groups #13037
Conversation
This would be a major breaking change. |
@GrahamCampbell explain please. |
You already explained it. Your before and afters are different. |
A PR that does the same was merged into It has the same effect if you use the However even without this PR, in the same example above if you applied I don't see a case where applying a middleware more than once is needed. |
Gah, I think we should revert that. |
@GrahamCampbell Is duplicated middleware intentional for some purposes? If not, what I can understand here is that two results of |
I believe forcing unique middlewares is a safety net that prevents executing a code multiple times while it should be executed once. Anyway if someone is depending on a middleware being applied multiple times intentionally yes this would be considered breaking, it depends on how you see the matter: bug or feature. |
Incase someone wants to wrap something more than once. It can't be that common though. I'm fine with this for 5.3, but I think we should revert the existing break on 5.3. |
@@ -435,6 +435,10 @@ public function mergeWithLastGroup($new) | |||
*/ | |||
public static function mergeGroup($new, $old) | |||
{ | |||
if (isset($new['middleware'])) { | |||
$new['middleware'] = array_diff((array) $new['middleware'], (array) $old['middleware']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is $old['middleware'] always available here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually no, corrected. Sorry.
Yeah let's think about this for 5.3, if at all. I'm inclined to not really limit people in this way at all. |
@taylorotwell then I think #12911 should be reverted as it has the same effect. no? |
In a previous PR we handled the case of applying a middleware more than once using
Route::middleware()
however the case of nested groups wasn't handled.Here's the case:
The middlewares extracted from this case are:
Before this PR: