Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When indexing an entity that is containing a rendered view mode results in a fatal error, when the view mode renders the breadcrumb in the template by e.g. using Twig tweak.
When running drush sapi-i you get the following error:
> [error] InvalidArgumentException while trying to render item entity:node/95:nl with view mode full for search index Elasticsearch: Route required in Drupal\Core\Url::fromRouteMatch() (line 159 of /vagrant/htdocs/web/core/lib/Drupal/Core/Url.php).
Modules using:
Steps to reproduce:
- Create a custom node with a custom template e.g. node--page.html.twig
- In the custom template print the following twig statement:
{{- drupal_breadcrumb() -}}
(this twig function is provided by Twig Tweak. - Create a Search API index.
- Add "Rendered item" as field in your index. As view mode, choose the view mode containing the drupal_breadcrumb() statement.
- Run drush sapi-i
- You now get the InvalidArgumentException error.
Comment | File | Size | Author |
---|---|---|---|
#5 | 3101533-5.patch | 756 bytes | jrockowitz |
| |||
#4 | 3101533-4.patch | 719 bytes | JeroenT |
|
Comments
Comment #2
JeroenTComment #3
JeroenTComment #4
JeroenTComment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedUsing
\Drupal::service('path.current')->getPath();
is going to be unpredictable via CLI. Instead let's make sure the route match object exists.Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #8
JeroenTThanks. Patch is working as expected.