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 !
Comments
Comment #2
davidajnered commentedI'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?
Comment #3
davidajnered commentedI created a patch to solve the issue quickly, but a better solution would be nice.
Comment #4
khiem.nguyen commentedI created a patch. The #3 not success on my case.
Comment #5
khiem.nguyen commentedComment #6
ppblaauw commentedPatch in #5 solved the issue in my case
Comment #7
cristianalcaraz commentedPatch in #5 also solved the issue for me :)
Comment #8
vitalius2009 commentedDisregard this patch, it's the same for 8.x-1.8 version.
Comment #9
vitalius2009 commentedComment #10
t.maquin commentedPatch in #5 also solved the issue for me.
Comment #11
petr illekWorking for me with the patch in #5.
Comment #12
damienmckennaAs a reminder, when a patch is added to an issue please set the status to "needs review". Thank you.
Comment #13
guyspriggs23@gmail.com commentedPatch #5 solved my issue.
Comment #14
jlj commentedPatch #5 work for me too. Thanks.
Comment #15
nanakEven 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.
Comment #16
nanakComment #17
kybermanHi, 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
Comment #18
nanak@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:
Comment #19
oxy86 commentedPatch in #5 solved the issue for me (Drupal 8.9.7). After applying patch in #15, it also solved the issue (Drupal 9.3).
Comment #20
kaszarobertPatch #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.
Comment #21
wells#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::servicecalls. 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).Comment #23
wells