Problem/Motivation

After upgrading to Drupal 11, I see the following error while rendering a View, including in the Views preview area.

TypeError: Drupal\Core\Render\Renderer::doRender(): Argument `#1` ($elements) must be of type array, null given, called in /var/www/web/core/lib/Drupal/Core/Render/Renderer.php on line 222 in Drupal\Core\Render\Renderer->doRender() (line 265 of core/lib/Drupal/Core/Render/Renderer.php).

Drupal\Core\Render\Renderer->render(NULL) (Line: 56)
Drupal\html_title\Plugin\views\field\NodeHtmlTitle->renderText(Array) (Line: 1260)
Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object) (Line: 230)
template_preprocess_views_view_field(Array, 'views_view_field', Array)
...

Steps to reproduce

Only occurs in Drupal 11

  1. Add an entity reference (node) field to a taxonomy.
  2. Create a taxonomy term, but do NOT reference any nodes in this field.
  3. Create a view that is a Taxonomy Term based view.
    • Add a relationship to content based on the entity reference field. ("Content referenced from field_test_node_reference")
    • Add a contextual filter "Taxonomy term: Term ID" with fixed value of the id of your test term.
    • You should now see your term name in the Views preview area.
    • Add the Content Title field, using the relationship.
  4. The view Preview will now crash with a console error!

Proposed resolution

The attached patch uses "empty" to check if the $alter['rendered'] array key exists before passing it to the renderer.

CommentFileSizeAuthor
#2 html_title-render-error-3537729-2.patch776 bytesjessehs

Issue fork html_title-3537729

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

jessehs created an issue. See original summary.

jessehs’s picture

Status: Active » Needs review
StatusFileSize
new776 bytes
bhogue’s picture

I can confirm that I was able to preview/create the view as per the instructions above without any crash/console error.

However, when I went to the page that my view was configured to display on, this error was displayed:

Debug: Calling Drupal\Core\Render\Renderer::render with NULL is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Either pass an array or skip the call. See https://www.drupal.org/node/3534020. in Drupal\Core\Render\Renderer->render() (line 215 of core/lib/Drupal/Core/Render/Renderer.php).
Drupal\Core\Render\Renderer->render() (Line: 54)
Drupal\html_title\Plugin\views\field\NodeHtmlTitle->renderText() (Line: 1260)
Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender() (Line: 230)
template_preprocess_views_view_field()
call_user_func_array() (Line: 302)
Drupal\Core\Theme\ThemeManager->Drupal\Core\Theme\{closure}() (Line: 326)
Drupal\Core\Theme\ThemeManager->render() (Line: 499)
Drupal\Core\Render\Renderer->doRender() (Line: 229)
Drupal\Core\Render\Renderer->render() (Line: 1811)
Drupal\views\Plugin\views\field\FieldPluginBase->theme() (Line: 778)
Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow()
call_user_func_array() (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 908)
Drupal\Core\Render\Renderer->doCallback() (Line: 440)
Drupal\Core\Render\Renderer->doRender() (Line: 229)
Drupal\Core\Render\Renderer->render() (Line: 715)
Drupal\views\Plugin\views\style\StylePluginBase->renderFields() (Line: 579)
Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping() (Line: 467)
Drupal\views\Plugin\views\style\StylePluginBase->render() (Line: 2213)
Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1595)
Drupal\views\ViewExecutable->render() (Line: 201)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1692)
Drupal\views\ViewExecutable->executeDisplay() (Line: 80)
Drupal\views\Element\View::preRenderViewElement()
call_user_func_array() (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 908)
Drupal\Core\Render\Renderer->doCallback() (Line: 440)
Drupal\Core\Render\Renderer->doRender() (Line: 229)
Drupal\Core\Render\Renderer->render() (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 633)
Drupal\Core\Render\Renderer::Drupal\Core\Render\{closure}()
Fiber->start() (Line: 634)
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: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
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: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 715)
Drupal\Core\DrupalKernel->handle() (Line: 19)
jessehs’s picture

@bhogue, I was testing with Drupal 11.2.2. Perhaps you are using a dev release. It looks like a fix for this was committed to 11.2.x and 11.3.x recently:

https://www.drupal.org/project/drupal/issues/3524738

However, this patch should still be committed since this code will break again in Drupal 12.

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

vitaliyb98’s picture

This issue is still relevant. While it can be avoided by enabling "Require this relationship" on the relationship, I recommend applying this fix to prevent unnecessary errors.

I’ve also added a test to cover this fix.

vitaliyb98’s picture

Status: Needs review » Fixed

Merged into 8.x-1.x, thanks

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

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

Maintainers, please credit people who helped resolve this issue.

  • c67214e7 committed on 8.x-1.x
    Issue #3537729 by vitaliyb98: Convert patch to MR (improved code), added...

Status: Fixed » Closed (fixed)

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