SocialBase theme causes LogicException by unsetting #lazy_builder without #create_placeholder

Created on 24 July 2025, 10 days ago

Problem/Motivation

The socialbase theme's Node preprocess function unsets the `#lazy_builder` property from node links but fails to unset the corresponding `#create_placeholder` property. This leaves the render array in an invalid state and causes a LogicException:

LogicException: When #create_placeholder is set, a #lazy_builder callback must be present as well. in Drupal\Core\Render\Renderer->doRender()

This error occurs when modules like flag, computed_field, or others add both `#lazy_builder` and `#create_placeholder` to node links, and then socialbase processes the node and removes only the lazy_builder.

#lazy_builder, #create_placeholder change record:
https://www.drupal.org/node/2498803 β†’

Steps to reproduce

1. Install Open Social with modules that add lazy builders to node links (e.g., flag, computed_field)
2. View a node in full view mode that has links with lazy builders
3. The socialbase theme executes the lazy builder callback and unsets `#lazy_builder`
4. The render system encounters `#create_placeholder = TRUE` without a `#lazy_builder` and throws an exception

In `themes/socialbase/src/Plugin/Preprocess/Node.php` around line 309:

// The theme executes the lazy builder callback directly
$variables['content']['links'] = array_merge(
  $variables['content']['links'],
  call_user_func_array(
    $variables['content']['links']['#lazy_builder'][0],
    $variables['content']['links']['#lazy_builder'][1]
  )
);
// Then unsets the lazy_builder
unset($variables['content']['links']['#lazy_builder']);

// BUT does not unset #create_placeholder!

Proposed resolution

When unsetting `#lazy_builder`, also unset the corresponding `#create_placeholder` property to maintain a valid render array state.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.6

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States SocialNicheGuru

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @SocialNicheGuru
  • πŸ‡ΊπŸ‡ΈUnited States SocialNicheGuru

    The website encountered an unexpected error. Try again later.

    LogicException: When #create_placeholder is set, a #lazy_builder callback must be present as well. in Drupal\Core\Render\Renderer->doRender() (line 401 of core/lib/Drupal/Core/Render/Renderer.php).
    Drupal\Core\Render\Renderer->doRender() (Line: 503)
    Drupal\Core\Render\Renderer->doRender() (Line: 248)
    Drupal\Core\Render\Renderer->render() (Line: 484)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 127)
    __TwigTemplate_07ccfefa48c43493cb57d5004a6ed750->block_nodefull_body() (Line: 432)
    Twig\Template->yieldBlock() (Line: 87)
    __TwigTemplate_07ccfefa48c43493cb57d5004a6ed750->doDisplay() (Line: 388)
    Twig\Template->yield() (Line: 344)
    Twig\Template->display() (Line: 359)
    Twig\Template->render() (Line: 51)
    Twig\TemplateWrapper->render() (Line: 33)
    twig_render_template() (Line: 348)
    Drupal\Core\Theme\ThemeManager->render() (Line: 490)
    Drupal\Core\Render\Renderer->doRender() (Line: 248)
    Drupal\Core\Render\Renderer->render() (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 637)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    call_user_func() (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 54)
    Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->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: 43)
    Drupal\webform_product\RedirectMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)

  • πŸ‡ΊπŸ‡ΈUnited States SocialNicheGuru
Production build 0.71.5 2024