Problem/Motivation
We receive this exception on pages with disabled menu links after upgrading from Drupal core 11.2 to 11.3.
Applying the patch from #2973515: MenuActiveTrail should ignore disabled menu links resolves it.
I realize it is most likely more of an issue in core, but since it breaks menu_breadcrumb, thought I would post here for anyone else who runs into this.
Error: Call to a member function getUrl() on null in Drupal\menu_breadcrumb\MenuBasedBreadcrumbBuilder->build() (line 364 of modules/contrib/menu_breadcrumb/src/MenuBasedBreadcrumbBuilder.php).
Drupal\Core\Breadcrumb\BreadcrumbManager->build() (Line: 73)
Drupal\system\Plugin\Block\SystemBreadcrumbBlock->build() (Line: 106)
Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray->onBuildRender() (Line: 246)
Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 117)
Drupal\layout_builder\SectionComponent->toRenderArray() (Line: 88)
Drupal\layout_builder\Section->toRenderArray() (Line: 349)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildSections() (Line: 309)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple() (Line: 365)
Drupal\Core\Entity\EntityViewBuilder->buildComponents() (Line: 29)
Drupal\node\NodeViewBuilder->buildComponents() (Line: 307)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (Line: 264)
Drupal\Core\Entity\EntityViewBuilder->build()
call_user_func_array() (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 910)
Drupal\Core\Render\Renderer->doCallback() (Line: 441)
Drupal\Core\Render\Renderer->doRender() (Line: 230)
Drupal\Core\Render\Renderer->render() (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 634)
Drupal\Core\Render\Renderer::Drupal\Core\Render\{closure}()
Fiber->resume() (Line: 649)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 235)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 131)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() (Line: 246)
Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 188)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 118)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 92)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 745)
Drupal\Core\DrupalKernel->handle() (Line: 19)
Steps to reproduce
Visit a page with a menu item that happens to be disabled, while using this module and Drupal 11.3.
Proposed resolution
Apply the patch from this MR to your site:
https://www.drupal.org/project/drupal/issues/2973515
Could possibly update this module to ignore disabled menu items as well.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3567562-8.patch | 2.7 KB | gcb |
Issue fork menu_breadcrumb-3567562
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
john.oltman commentedComment #3
cafuego commentedComment #4
cafuego commentedSadly the patch from the related issue does not fix my problem.
Comment #7
orakili commentedCreated MR with a simple fix that checks the links array is not empty. This solves the issue on our side.
Comment #8
gcbAttaching the MR as a patch for stable use in builds.
Comment #9
cafuego commentedSeems to work as advertised :-)
Comment #12
xurizaemonThanks team!