Drupal 8.1.7
Bootstrap 8.x-3.x-dev (0c541a1)

Example 1 - Saving Bootstrap theme settings page:

The website encountered an unexpected error. Please try again later.

LogicException: Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead. in Drupal\Core\Render\Renderer->doRender() (line 241 of core/lib/Drupal/Core/Render/Renderer.php).

Drupal\Core\Render\Renderer->render(Array) (Line: 97)
Drupal\bootstrap\Plugin\Setting\SettingBase->getElement(Array, Object) (Line: 25)
Drupal\bootstrap\Plugin\Setting\SettingBase->alterForm(Array, Object, NULL) (Line: 49)
Drupal\bootstrap\Plugin\Setting\Components\Region\RegionWells->alterForm(Array, Object) (Line: 38)
Drupal\bootstrap\Plugin\Form\SystemThemeSettings->alterForm(Array, Object, NULL) (Line: 207)
Drupal\bootstrap\Bootstrap::alter('bootstrap_form_system_theme_settings_alter', Array, Object, NULL) (Line: 74)
bootstrap_form_system_theme_settings_alter(Array, Object) (Line: 326)
Drupal\system\Form\ThemeSettingsForm->buildForm(Array, Object, 'bootstrap')
call_user_func_array(Array, Array) (Line: 512)
Drupal\Core\Form\FormBuilder->retrieveForm('system_theme_settings', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
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: 98)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 627)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Example 2 - Submitting comments:

LogicException: Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead. in Drupal\Core\Render\Renderer->doRender() (line 241 of core/lib/Drupal/Core/Render/Renderer.php).

Drupal\Core\Render\Renderer->render(Array) (Line: 478)
Drupal\bootstrap\Utility\Element->render() (Line: 155)
Drupal\bootstrap\Plugin\ProcessManager::processInputGroups(Object, Object, Array) (Line: 82)
Drupal\bootstrap\Plugin\ProcessManager::process(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 979)
Drupal\Core\Form\FormBuilder->doBuildForm('comment_media_comment_form', Array, Object) (Line: 1042)
Drupal\Core\Form\FormBuilder->doBuildForm('comment_media_comment_form', Array, Object) (Line: 1042)
Drupal\Core\Form\FormBuilder->doBuildForm('comment_media_comment_form', Array, Object) (Line: 555)
Drupal\Core\Form\FormBuilder->processForm('comment_media_comment_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 251)
Drupal\comment\Controller\CommentController->getReplyForm(Object, Object, 'field_media_comments', NULL)
call_user_func_array(Array, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
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: 98)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 627)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

..and maybe other places I haven't found yet?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

steveoliver created an issue. See original summary.

steveoliver’s picture

Issue summary: View changes

Specified Bootstrap version commit id.

steveoliver’s picture

Status: Needs work » Needs review
FileSize
938 bytes

Fixes issue for Examples 1 and 2.

markhalliwell’s picture

As stated in IRC, I haven't encountered these errors in either scenario.

@steveoliver suggests that it may be some other contrib code interfering with this.

Regarding the patch, I'd rather not change the method called in render and instead add a new subsequent renderPlain, and renderRoot wrappers. I can do this is a separate issue.

This one should likely be focused on replacing existing calls to this method with the appropriate method call.

markhalliwell’s picture

Assigned: steveoliver » markhalliwell
Status: Needs review » Needs work
Related issues: +#2779313: Add missing render methods on Element utility class

Ok. I added those methods. I'm going to work on trying to replace all these instances with the proper call and upload a patch here for you to try.

markhalliwell’s picture

Title: LogicException: render() was called outside of a renderRoot() or renderPlain() call » Use renderPlain instead of render
markhalliwell’s picture

Assigned: markhalliwell » Unassigned
Status: Needs work » Needs review
Related issues: +#2779327: Add the ability to create a standalone Element object from a new array
FileSize
9.14 KB

Ok, here's a more comprehensive patch. See if this works.

Note: this includes a few changes to simplify syntax with the addition of the related issue I'm attaching now.

Edit: you should download a new dev before applying this patch (if that wasn't obvious)

steveoliver’s picture

Status: Needs review » Reviewed & tested by the community

looks good, works as expected!

  • markcarver committed 8616a48 on 8.x-3.x
    Issue #2779295 by steveoliver, markcarver: Use renderPlain instead of...
markhalliwell’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

jasonsavino’s picture

Drupal 8.4.2
Bootstrap 8.x-3.7

I found a similar issue when adding Search via Context. I was able to fix it and have included the patch file.

LogicException: Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call.
Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead. in Drupal\Core\Render\Renderer->doRender() (line 241 of core/lib/Drupal/Core/Render/Renderer.php). 
Drupal\Core\Render\Renderer->render(Array) (Line: 544)
Drupal\bootstrap\Utility\Element->render() (Line: 130)
Drupal\bootstrap\Plugin\ProcessManager::processInputGroups(Object, Object, Array) (Line: 75)
Drupal\bootstrap\Plugin\ProcessManager::process(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 993)
Drupal\Core\Form\FormBuilder->doBuildForm('search_block_form', Array, Object) (Line: 1056)
Drupal\Core\Form\FormBuilder->doBuildForm('search_block_form', Array, Object) (Line: 557)
Drupal\Core\Form\FormBuilder->processForm('search_block_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('Drupal\search\Form\SearchBlockForm', Object) (Line: 212)
Drupal\Core\Form\FormBuilder->getForm('Drupal\search\Form\SearchBlockForm') (Line: 31)
Drupal\search\Plugin\Block\SearchBlock->build() (Line: 212)
Drupal\context\Plugin\ContextReaction\Blocks->execute(Array, Object, Array) (Line: 109)
Drupal\context\Plugin\DisplayVariant\ContextBlockPageVariant->build() (Line: 259)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 108)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
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: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
BigEd’s picture

@jasonsavino Thanks I had the same issue with Search via Context, I also was having an issue in the region of the block but this solved my issue. Thanks.