The current page gets added twice - from the menu item and from MenuBasedBreadcrumbBuilder::addMissingCurrentPage
because the route parameter check is too strict.
e.g these are considered different:
array:3 [▼
"taxonomy_term" => "46377"
"display_id" => "page_1"
"view_id" => "taxonomy_term"
]

VS

array:3 [▼
"taxonomy_term" => "46377"
"view_id" => "taxonomy_term"
"display_id" => "page_1"
]

Command icon 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

van.dordafog created an issue. See original summary.

van.dordafog’s picture

StatusFileSize
new707 bytes
mradcliffe’s picture

I am also getting this. The patch resolved the issue for taxonomy term pages via views, but there is also a duplicate crumb when visiting views pages in the menu.

Maybe this module needs something like Easy Breadcrumb's removeRepeatedSegments?

van.dordafog changed the visibility of the branch 3505550-strict-route-parameter to hidden.

van.dordafog changed the visibility of the branch 3505550-stict-route to hidden.

van.dordafog changed the visibility of the branch 2.0.x to hidden.

van.dordafog’s picture

Status: Active » Needs review
csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new282.06 KB
new257.67 KB

Environment

  • Drupal: 11.4.4
  • PHP: 8.5.5
  • Database: MariaDB 10.11.16
  • DDEV: v1.25.2
  • Menu Breadcrumb: 2.0.x-dev (403ce36)
  • Browser: Chrome

Prerequisites

  • Install and enable the module on the branch the issue targets:
ddev composer require 'drupal/menu_breadcrumb:2.0.x-dev@dev'
ddev drush en menu_breadcrumb -y
  • Core's taxonomy_term view must be enabled (default), so that the term page route carries the view_id and display_id parameters.
  • Create a term and a main menu link pointing at it:
ddev drush php:eval '
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\taxonomy\Entity\Term;
use Drupal\menu_link_content\Entity\MenuLinkContent;
if (!Vocabulary::load("tags")) { Vocabulary::create(["vid" => "tags", "name" => "Tags"])->save(); }
$term = Term::create(["vid" => "tags", "name" => "Breadcrumb Test Term"]);
$term->save();
MenuLinkContent::create([
  "title" => "Breadcrumb Test Term",
  "link" => ["uri" => "internal:/taxonomy/term/" . $term->id()],
  "menu_name" => "main",
])->save();
print $term->id();
'
  • Enable the Main navigation menu at /admin/config/user-interface/menu-breadcrumb and tick Append current page to breadcrumb. Without the append option the module drops the last crumb, which hides the duplicate.
  • Log in as administrator: ddev drush uli

Steps

  1. Before applying anything, visit /taxonomy/term/1 and look at the breadcrumb.
  2. Apply the fix from MR !36: in MenuBasedBreadcrumbBuilder::addMissingCurrentPage() the route parameter comparison changes from === to ==.
  3. Rebuild caches: ddev drush cr
  4. Visit /taxonomy/term/1 again and compare the breadcrumb.
  5. Visit a term page that has no menu link (e.g. /taxonomy/term/2) and a node page to confirm nothing else changed.

Expected results

  • The term page breadcrumb reads Home › Breadcrumb Test Term — the current page appears exactly once.
  • Pages whose current page is genuinely missing from the menu trail are unaffected.

Actual results

Before the fix the breadcrumb on /taxonomy/term/1 read Home › Breadcrumb Test Term › Breadcrumb Test Term. The menu link stores its route parameters as taxonomy_term, display_id, view_id, while the route match returns them as taxonomy_term, view_id, display_id; both arrays hold the same key/value pairs but in a different order, so the === comparison failed and addMissingCurrentPage() appended the current page on top of the menu link. After applying MR !36 the breadcrumb read Home › Breadcrumb Test Term. A term page without a menu link and a node page were checked afterwards and produced the same breadcrumbs as before the change, so the loosened comparison does not suppress a legitimately missing current page.


Testing produced with the assistance of an LLM.

xurizaemon made their first commit to this issue’s fork.

xurizaemon’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

csakiistvan’s picture

Assigned: csakiistvan » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.