[6.x] Fix nav:breadcrumbs including home when include_home is false - #15244
Open
wakqasahmed wants to merge 2 commits into
Open
[6.x] Fix nav:breadcrumbs including home when include_home is false#15244wakqasahmed wants to merge 2 commits into
wakqasahmed wants to merge 2 commits into
Conversation
…ic#12584) When include_home is false, array_shift() removed the leading home segment, but a root URL left a trailing empty segment that URL::tidy() normalized back to '/', which then resolved to the Home entry. Filter out empty segments after the shift so they never reach tidy()/findByUri().
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.
What
{{ nav:breadcrumbs include_home="false" }}still showed the home entry when the current page resolved to a root-adjacent segment.Why
In
breadcrumbs(), wheninclude_homeisfalse,array_shift($segments)drops the leading/marker. When the current URL is the site root (/), the remaining segments array is left containing a single empty string. That empty string is then imploded and passed throughURL::tidy(), which normalizes an empty string back to/, andData::findByUri('/')resolves that to the Home entry — reintroducing the crumb the caller explicitly asked to exclude.Fix
After shifting off the home segment, filter out any resulting empty segments before building URIs, so an empty/root segment is never fed into
tidy()/findByUri().Test plan
tests/Tags/NavBreadcrumbsTest.phpcovering:include_homebehavior (home included)include_home="false"on a nested page (home excluded, other crumbs intact)include_home="false"on a top-level pageinclude_home="false"while viewing the home page itself (no breadcrumbs at all, previously incorrectly returned the home crumb)Fixes #12584