Repository navigation
[13.x] Fix the previous route leaking into 404 requests under Octane - #62123
Merged
Merged
Conversation
Contributor
|
Thanks for pointing this! I though it was Octane... I was able to fix my issue with middleware In case it can help someone, this is my code: EnsureFeaturesAreActive::whenInactive(function (Request $request, array $features): never {
/**
* The breadcrumbs manager (`Diglactic\Breadcrumbs\Manager`) uses the router's current route
* to resolve the page title. When a route is registered for a feature that is inactive, the manager
* would otherwise generate a breadcrumb for that (now inaccessible) route, resulting in an
* incorrect title. By clearing the protected `$current` property of the router, the manager falls
* back to the built‑in 404 route (`['errors.404', []]`) and the breadcrumb title is hidden.
*/
new ReflectionClass($router = app(Router::class))
->getProperty('current')
->setValue($router, null);
abort(404);
}); |
binaryfire
added a commit
to hypervel/components
that referenced
this pull request
Nov 1, 2026
Move coroutine-local current-route clearing into findRoute before Routing listeners run. Both dispatch and direct dispatchToRoute now clear stale route state, including failed route matching, without duplicate writes on ordinary dispatch. Completes laravel/framework#62123 behavior compared at 13.x revision 5d7797528723107cd4f495326838a7d7d67fbb20 while retaining coroutine isolation. Verified complete RoutingRouteTest and RouterExtensionTest files, full static analysis and formatting.
binaryfire
added a commit
to hypervel/components
that referenced
this pull request
Nov 1, 2026
Keep current-route resetting in dispatch, matching laravel/framework#62123 at 13.x revision 5d7797528723107cd4f495326838a7d7d67fbb20, and mirror it in Hypervel's callback dispatch entrypoint. Do not reset in findRoute: a failed direct dispatchToRoute must preserve the active route as upstream does. Both request entrypoints still clear stale state before Routing listeners, without adding a route stack or extra normal-path context writes. A real nested route test reproduces Router::input failing after a caught missing-route exception before this correction. The complete RoutingRouteTest and RouterExtensionTest files, targeted source analysis and formatting pass.
albertcht
pushed a commit
to hypervel/routing
that referenced
this pull request
Nov 1, 2026
Port laravel/framework#62123 from 835946cb1608a309be92141feae6be438639fbff, reconciled against the frozen 13.x source. A route miss must not expose the route from an earlier dispatch in the same coroutine. Reset only the coroutine-local current route at the public dispatch boundary, preserving request isolation and dispatchToRoute customization. Port every upstream regression assertion; the test fails before the reset and the complete RoutingRouteTest passes afterward. Static analysis and formatting pass.
albertcht
pushed a commit
to hypervel/routing
that referenced
this pull request
Nov 1, 2026
Move coroutine-local current-route clearing into findRoute before Routing listeners run. Both dispatch and direct dispatchToRoute now clear stale route state, including failed route matching, without duplicate writes on ordinary dispatch. Completes laravel/framework#62123 behavior compared at 13.x revision 5d7797528723107cd4f495326838a7d7d67fbb20 while retaining coroutine isolation. Verified complete RoutingRouteTest and RouterExtensionTest files, full static analysis and formatting.
albertcht
pushed a commit
to hypervel/routing
that referenced
this pull request
Nov 1, 2026
Keep current-route resetting in dispatch, matching laravel/framework#62123 at 13.x revision 5d7797528723107cd4f495326838a7d7d67fbb20, and mirror it in Hypervel's callback dispatch entrypoint. Do not reset in findRoute: a failed direct dispatchToRoute must preserve the active route as upstream does. Both request entrypoints still clear stale state before Routing listeners, without adding a route stack or extra normal-path context writes. A real nested route test reproduces Router::input failing after a caught missing-route exception before this correction. The complete RoutingRouteTest and RouterExtensionTest files, targeted source analysis and formatting pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The router sets
$currentwhen a route matches, but never clears it. So when the next request doesn't match anything,match()throws a 404 and$currentstill holds the previous request's route, along with its bound parameters.With PHP-FPM this doesn't matter, but Octane reuses the router between requests:
Anything that reads the current route while the 404 is rendered or reported gets the previous request's data. For example,
diglactic/laravel-breadcrumbstreats a missing current route as the 404 page, so under Octane the 404 page shows the previous request's breadcrumbs instead: https://github.com/diglactic/laravel-breadcrumbs/blob/main/src/Manager.php#L238-L244This clears
$currentat the start ofdispatch(), so a request that doesn't match a route has no current route, same as on PHP-FPM.