[6.x] Only add site view paths for directories that exist - #15325
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FXkAMcSNRi2Vcpzb3QdiqC
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.
This pull request fixes an issue where the
AddViewPathsmiddleware 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 viewfile_exists()probes were for directories that have never existed. On hosts withopen_basedirset (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