Skip to content

Conversation

@ryzr
Copy link
Contributor

@ryzr ryzr commented Nov 26, 2025

PR #57871 introduced a very slight change to the behaviour of matching fallback routes.

Before #57871: Return first non-fallback route match, otherwise return first fallback route match.

After #57871: Return the second matching fallback route (if one exist), otherwise return the first non-fallback route match, otherwise return the first fallback route.

Reasoning:
After the first fallbackRoute is matched, the next fallbackRoute will no longer get caught by the ->isFallback guard, due to the === null check. This causes the next matching fallbackRoute to be returned, rather than continuing through the non-fallback routes.

To fix this, I've removed the === null check, causing the loop to continue. I used null coalescing assignment to ensure only the first fallback route is captured.

@ryzr ryzr changed the title [12.x] fix: don't return second fallback route if another route matches [12.x] fix: continue route matching rather than returning second fallbackRoute Nov 26, 2025
@bytestream
Copy link
Contributor

Noticed this too and this fixes it 👍🏼 . Think a test would be useful to prevent future regression.

@taylorotwell taylorotwell merged commit b249385 into laravel:12.x Nov 26, 2025
76 checks passed
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.

3 participants