Skip to content

[6.x] Fix @nocache TypeError when rendered outside a matched route - #15215

Open
lazerg wants to merge 2 commits into
statamic:6.xfrom
lazerg:fix/nocache-routeless-render
Open

[6.x] Fix @nocache TypeError when rendered outside a matched route#15215
lazerg wants to merge 2 commits into
statamic:6.xfrom
lazerg:fix/nocache-routeless-render

Conversation

@lazerg

@lazerg lazerg commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@nocache throws a TypeError instead of rendering when the enclosing view has no matched route. Cache::isBeingUsedOnCurrentRoute() passes request()->route() straight into Router::gatherRouteMiddleware(), which is typed to require a Route. When nothing has matched a route yet, that argument is null and the call fatals before BladeDirective::handle() ever reaches its existing fallback for routes where static caching isn't active.

This adds a null check so a routeless render is treated the same as any other route without the cache middleware: the region renders inline instead of crashing.

Fixes #15214

lazerg added 2 commits August 19, 2026 05:36
Rename BladeDirectiveTest to NocacheBladeTest to match the NocacheRouteTest/
NocacheTagsTest naming pattern in this directory, and use the existing
bladeViewPaths DefineEnvironment pattern (from HalfMeasureStaticCachingTest)
instead of an inline View::addLocation() call, which was the only such call
in the test suite.
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.

@nocache throws a TypeError when rendered outside a matched route

1 participant