Skip to content

[6.x] Only add site view paths for directories that exist - #15325

Merged
jasonvarga merged 1 commit into
6.xfrom
site-view-paths
Sep 1, 2026
Merged

[6.x] Only add site view paths for directories that exist#15325
jasonvarga merged 1 commit into
6.xfrom
site-view-paths

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where the AddViewPaths middleware doubles every front-end view lookup, even on single-site installs.

This was happening because the middleware prefixes every view path and namespace hint with a /<site> sibling without checking whether the directory exists. On a single-site install, those directories almost never exist, so around half of all view file_exists() probes were for directories that have never existed. On hosts with open_basedir set (most shared/managed hosting), this is much worse — PHP can't cache negative realpath lookups, so each miss re-walks the whole path on every call of every request.

This PR fixes it by only adding the site-prefixed path when the directory actually exists. This helps multi-site installs too, since even a five-site install usually only has override directories for a handful of its path entries. Site directories that do exist continue to be added ahead of their base path, so per-site template overrides behave exactly as before.

Fixes #15323

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXkAMcSNRi2Vcpzb3QdiqC
@jasonvarga
jasonvarga merged commit 7e6f184 into 6.x Sep 1, 2026
65 checks passed
@jasonvarga
jasonvarga deleted the site-view-paths branch September 1, 2026 13:48
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