Skip to content

[6.x] Don't add per-site view paths when there's only one site - #15326

Closed
lazerg wants to merge 2 commits into
statamic:6.xfrom
lazerg:fix/issue-15323-add-view-paths-single-site
Closed

[6.x] Don't add per-site view paths when there's only one site#15326
lazerg wants to merge 2 commits into
statamic:6.xfrom
lazerg:fix/issue-15323-add-view-paths-single-site

Conversation

@lazerg

@lazerg lazerg commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

The AddViewPaths middleware prefixes every view path and namespace hint with a /<site> sibling directory so a multi-site install can override templates per site. It does that on every front-end request, whether or not the install actually has more than one site.

On a single-site install those directories don't exist, so every prefixed entry is a guaranteed miss and the finder probes twice as many paths as it needs to. It's much worse on hosts that set open_basedir, since PHP can't cache a negative realpath lookup and each miss re-walks the whole path on every call. Counting the finder's file_exists() calls on a single-site install, a lookup went from 56 probes to 28 with the render unchanged.

This skips the middleware when there's only one site. Worth flagging: anyone on a one-site install who kept templates in resources/views/<site> would need to move them up a level. The issue also suggests filtering on is_dir() instead, which would help multi-site installs too, but that stats every path on every request, so I've kept this to the case that was reported.

Fixes #15323

@jasonvarga

Copy link
Copy Markdown
Member

Fixed in #15325

@jasonvarga jasonvarga closed this Sep 1, 2026
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.

AddViewPaths adds non-existent per-site view paths on single-site installs, doubling every view lookup

2 participants