Possible infinite loop in EasyBreadcrumbBuilder.php when 'Breadcrumb segment coun' is set to a negative value or is set to 0.
Patch needed.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | avoid-invinite-loop-when-breadcrumb-segment-count-gets-negative-3503872-3.patch | 582 bytes | drupalfan2 |
Issue fork easy_breadcrumb-3503872
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
drupalfan2 commentedComment #3
drupalfan2 commentedThe following patch avoids the infinite while loop.
Comment #6
sriram_s commentedOpened MR !167 to fix this.
Root cause: with "limit segment display" on, a segment count of 0 and the
home segment included, $segment_limit is decremented to -1; the trimming
loop condition count($links) > $segment_limit is then always true and
loops infinitely. A negative value entered directly hits the same path.
Fix: clamp the limit with max(0, $segment_limit) immediately before the
loop, which covers both the 0-with-home-segment case and directly-entered
negative values (broader than the original patch, which guarded only the
home-segment branch).
Tested on Drupal 11.4 / easy_breadcrumb 2.0.9: reproduced the hang with
segment count = 0 + home segment enabled, confirmed the page loads after
the fix, and verified a valid positive limit still trims correctly.
Note: the phpcs pipeline failures are pre-existing coding-standard issues
in files unrelated to this change (src/TitleResolver.php,
easy_breadcrumb.install, .tugboat/config.yml). This MR only edits
src/EasyBreadcrumbBuilder.php; the phpunit and phpstan jobs pass. Happy to
open a separate MR for the standards cleanup if wanted.
Thanks @drupalfan2 for the report and diagnosis.
Comment #7
greg boggs