Problem/Motivation

I get the error :

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\views\Render\ViewsRenderPipelineMarkup::render() in Drupal\schema_metatag\Plugin\schema_metatag\PropertyType\BreadcrumbList->getItems() (line 82 of modules/contrib/schema_metatag/src/Plugin/schema_metatag/PropertyType/BreadcrumbList.php).
Drupal\schema_metatag\Plugin\schema_metatag\PropertyType\BreadcrumbList->getItems('Yes') (Line: 48)
Drupal\schema_metatag\Plugin\schema_metatag\PropertyType\ItemListElement->outputValue('Yes') (Line: 54)
Drupal\schema_metatag\Plugin\schema_metatag\PropertyType\BreadcrumbList->outputValue('Yes') (Line: 189)
Drupal\schema_metatag\Plugin\metatag\Tag\SchemaNameBase->outputValue('Yes') (Line: 161)
Drupal\schema_metatag\Plugin\metatag\Tag\SchemaNameBase->output() (Line: 583)
Drupal\metatag\MetatagManager->generateRawElements(Array, Object) (Line: 493)
Drupal\metatag\MetatagManager->generateElements(Array, Object) (Line: 528)
metatag_get_tags_from_route() (Line: 126)
metatag_page_attachments(Array) (Line: 312)
Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array) (Line: 288)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 716)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

I upgrade from drupal 8.9.16 to 9.2.0
I do a search from the searchbox with Search API, it works.
As soon I click on a facet filter, it crashes.

Thanks for your help !

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

mchamps created an issue. See original summary.

davidajnered’s picture

I'm getting the same error after upgrading from Drupal 8 to 9. I had a quick look at the code and tried to find a solution but no luck so far. Line 82 in BreadcrumbList.php looks like this:

$text = is_object($text) ? $text->render() : $text;

An easy solution would be to extend this to check if $text is ViewsRenderPipelineMarkup and then don't call render(), but that kind of solution could easily grow large and ugly. Any ideas on how to approach this?

davidajnered’s picture

StatusFileSize
new867 bytes

I created a patch to solve the issue quickly, but a better solution would be nice.

khiem.nguyen’s picture

StatusFileSize
new834 bytes

I created a patch. The #3 not success on my case.

khiem.nguyen’s picture

StatusFileSize
new1.05 KB
ppblaauw’s picture

Patch in #5 solved the issue in my case

cristianalcaraz’s picture

Patch in #5 also solved the issue for me :)

vitalius2009’s picture

Disregard this patch, it's the same for 8.x-1.8 version.

vitalius2009’s picture

StatusFileSize
new1.08 KB
t.maquin’s picture

Patch in #5 also solved the issue for me.

petr illek’s picture

Working for me with the patch in #5.

damienmckenna’s picture

Status: Active » Needs review

As a reminder, when a patch is added to an issue please set the status to "needs review". Thank you.

guyspriggs23@gmail.com’s picture

Patch #5 solved my issue.

jlj’s picture

Patch #5 work for me too. Thanks.

nanak’s picture

Version: 8.x-2.2 » 8.x-2.x-dev
StatusFileSize
new1.53 KB
new1.53 KB

Even though the attached patch does solve the issue described, I see two problems:
- It introduces a dependency to the views module
- The instance check is too specific: the same issue may arise for different classes.

I propose a simpler approach: The Link objects returned by the breadcrumb builder can return three types: string, array or MarkupInterface. Objects implementing the MarkupInterface must have a __toString(), meaning objects will be converted to string when needed.
Finally, this patch adds support to render array being returned by Link::getText(), by rendering it.

nanak’s picture

kyberman’s picture

Hi, I checked this issue probably has a much easier solution:
1. The breadcrumb "->getLinks()" method returns list of "\Drupal\Core\Link" objects.
2. The link "->getText()" method already returns a "string", "array", or "\Drupal\Component\Render\MarkupInterface" object.
3. The "getItems()" method output should be a renderable array, so we don't need to render values ourselves.

I'm attaching patches for both branches.
Could you please review and test if it works for you too?

Thank you
Vit

nanak’s picture

@kyberman the third assumption is wrong, getItems() do not return a render array, but a basic associative array. I've tried to pass a simple render array in the name key, and it was printed as a json representation of this array:

"itemListElement": [
    {
        "@type": "ListItem",
        "position": 1,
        "name": {
            "#markup": "Link title"
        },
        "item": "https://example.com"
    }
]
oxy86’s picture

Patch in #5 solved the issue for me (Drupal 8.9.7). After applying patch in #15, it also solved the issue (Drupal 9.3).

kaszarobert’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

Patch #15 fixes our issues after upgrading the module on Drupal 9.3:
- If pathauto module is also enabled, and taxonomy term hierarchy is used in a node path alias (so BreadcrumbList at least 3 items), then the site produces WSOD with the error described in this issue summary for this kind of URL: /term-parent/term-child/node-article
- Also, 404 and 403 error pages produce WSOD with a URL like this: /xxxxx/xxxxx/xxxx, same error happens.
The patch fixes both use cases.

I'm raising the priority to Critical because this problem completely breaks certain pages on the website currently.

wells’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.7 KB
new2.48 KB

#15 looks like the most flexible solution. I've made a few small additions just because this is introducing an opportunity to remove some \Drupal::service calls. New patch and interdiff attached and I'll be merging this in to 8.x-2.x (perhaps notably, not 8.x-1.x, see #3264566: Seeking co-maintainers if you're interested in helping support older branches).

  • wells committed ba4369f on 8.x-2.x authored by davidajnered
    Issue #3222429 by nanak, khiem.nguyen, vitalius2009, kyberman, wells,...
wells’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

goutham-veluru made their first commit to this issue’s fork.