Skip to content

[12.x] fix: continue route matching rather than returning second fallbackRoute#57922

Merged
taylorotwell merged 1 commit into
laravel:12.xfrom
ryzr:patch-30
Nov 26, 2025
Merged

[12.x] fix: continue route matching rather than returning second fallbackRoute#57922
taylorotwell merged 1 commit into
laravel:12.xfrom
ryzr:patch-30

Conversation

@ryzr

@ryzr ryzr commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
akyrey pushed a commit to akyrey/framework that referenced this pull request Dec 29, 2025
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