Problem/Motivation
We have multiple PHP errors:
User error: "title" is an invalid render array key in Drupal\Core\Render\Element::children() (line 98 of core/lib/Drupal/Core/Render/Element.php).
Drupal\Core\Render\Element::children(Array, 1) (Line: 404)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 245)
__TwigTemplate_99e95fbb658070869d19a215177e3c8a->macro_leo_render_tree_level(Array) (Line: 1169)
twig_call_macro(Object, 'macro_leo_render_tree_level', Array, 28, Array, Object) (Line: 174)
__TwigTemplate_99e95fbb658070869d19a215177e3c8a->macro_leo_render_tree_level(Array) (Line: 1169)
twig_call_macro(Object, 'macro_leo_render_tree_level', Array, 28, Array, Object) (Line: 174)
__TwigTemplate_99e95fbb658070869d19a215177e3c8a->macro_leo_render_tree_level(Array, 'added') (Line: 1169)
twig_call_macro(Object, 'macro_leo_render_tree_level', Array, 6, Array, Object) (Line: 110)
__TwigTemplate_99e95fbb658070869d19a215177e3c8a->macro_leo_render_tree_level(Array, NULL, 1) (Line: 1169)
twig_call_macro(Object, 'macro_leo_render_tree_level', Array, 85, Array, Object) (Line: 63)
__TwigTemplate_99e95fbb658070869d19a215177e3c8a->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('modules/contrib/log_entity_operations/log_entity_operations_entity/templates/log-entity-operations-json-collapsible.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('log_entity_operations_json_collapsible', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 934)
Drupal\views\Plugin\views\field\EntityField->render_item(0, Array) (Line: 1170)
Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object) (Line: 239)
template_preprocess_views_view_field(Array, 'views_view_field', Array)
call_user_func_array('template_preprocess_views_view_field', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('views_view_field', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 1746)
Drupal\views\Plugin\views\field\FieldPluginBase->theme(Object) (Line: 777)
Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow(Array)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 788)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 374)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 716)
Drupal\views\Plugin\views\style\StylePluginBase->renderFields(Array) (Line: 582)
Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping(Array, Array, 1) (Line: 473)
Drupal\views\Plugin\views\style\StylePluginBase->render(Array) (Line: 2169)
Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1538)
Drupal\views\ViewExecutable->render() (Line: 199)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1635)
Drupal\views\ViewExecutable->executeDisplay('page_1', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 788)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 374)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 243)
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: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\http_headers_cleaner\Middleware\HttpHeadersCleanerMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
The errors come from log-entity-operations-json-collapsible.html.twig.
{% elseif data.type == 'value_layer' %}
<table>
<thead>
<tr>
<th>{{ "Field Name"|t }}</th>
<th>{{ "Value"|t }}</th>
</tr>
</thead>
<tbody>
{% for key, value in data.values %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
In some cases, in the value_layer, is possible that the value could be a not valid renderable variable, and in those cases, it produces an error.
Steps to reproduce
- Enable log_entity_operations_entity.
- Enable views for log entity operations.
Disable the cache tag from the log entity operations view.
- Make a change on any view to create a new registry on the log operations.
- Visit the log entity operations views, and the PHP error will appear.
Proposed resolution
In the case of the value is an array, then print as JSON.