Warning: Undefined array key "rendered_entity" in template_preprocess_views_view_datatables() (Zeile 66 in /web/modules/contrib/datatables/datatables.module)

Created on 29 June 2023, over 1 year ago
Updated 31 January 2024, 10 months ago

Problem/Motivation

Warning: Undefined array key "rendered_entity" in template_preprocess_views_view_datatables() (line 66 of web/modules/contrib/datatables/datatables.module).:
β§‰βŒ•array (46)

    ⇄⧉45: template_preprocess_views_view_datatables() => array (2)

    ⇄⧉44: call_user_func_array() => array (1)

    ⇄⧉43: Drupal\Core\Theme\ThemeManager->render() => array (2)

    ⇄⧉42: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉41: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉40: Drupal\Core\Render\Renderer->render() => array (2)

    ⇄⧉39: Drupal\Core\Template\TwigExtension->escapeFilter() => array (2)

    ⇄⧉38: __TwigTemplate_246c7880ec61d644e3ca38f7ed46c129->doDisplay() => array (2)

    ⇄⧉37: Twig\Template->displayWithErrorHandling() => array (2)

    ⇄⧉36: Twig\Template->display() => array (2)

    ⇄⧉35: Twig\Template->render() => array (2)

    ⇄⧉34: twig_render_template() => array (2)

    ⇄⧉33: Drupal\Core\Theme\ThemeManager->render() => array (2)

    ⇄⧉32: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉31: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉30: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉29: Drupal\Core\Render\Renderer->render() => array (2)

    ⇄⧉28: Drupal\Core\Template\TwigExtension->escapeFilter() => array (2)

    ⇄⧉27: __TwigTemplate_b3fb697e04e2fe18282f8c11c6b260a9->doDisplay() => array (2)

    ⇄⧉26: Twig\Template->displayWithErrorHandling() => array (2)

    ⇄⧉25: Twig\Template->display() => array (2)

    ⇄⧉24: Twig\Template->render() => array (2)

    ⇄⧉23: twig_render_template() => array (2)

    ⇄⧉22: Drupal\Core\Theme\ThemeManager->render() => array (2)

    ⇄⧉21: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉20: Drupal\Core\Render\Renderer->render() => array (2)

    ⇄⧉19: Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() => array (1)

    ⇄⧉18: Drupal\Core\Render\Renderer->executeInRenderContext() => array (2)

    ⇄⧉17: Drupal\Core\Render\MainContent\HtmlRenderer->prepare() => array (2)

    ⇄⧉16: Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() => array (2)

    ⇄⧉15: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() => array (2)

    ⇄⧉14: call_user_func() => array (1)

    ⇄⧉13: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() => array (2)

    ⇄⧉12: Symfony\Component\HttpKernel\HttpKernel->handleRaw() => array (2)

    ⇄⧉11: Symfony\Component\HttpKernel\HttpKernel->handle() => array (2)

    ⇄⧉10: Drupal\Core\StackMiddleware\Session->handle() => array (2)

    ⇄⧉ 9: Drupal\Core\StackMiddleware\KernelPreHandle->handle() => array (2)

    ⇄⧉ 8: Drupal\page_cache\StackMiddleware\PageCache->pass() => array (2)

    ⇄⧉ 7: Drupal\page_cache\StackMiddleware\PageCache->handle() => array (2)

    ⇄⧉ 6: Drupal\ban\BanMiddleware->handle() => array (2)

    ⇄⧉ 5: Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() => array (2)

    ⇄⧉ 4: Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() => array (2)

    ⇄⧉ 3: Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle() => array (2)

    ⇄⧉ 2: Stack\StackedHttpKernel->handle() => array (2)

    ⇄⧉ 1: Drupal\Core\DrupalKernel->handle() => array (2)

    ⇄⧉ 0: main() => array (2)

⧉ Called from <ROOT>/modules/contrib/datatables/datatables.module:66 [backtrace_error_handler()]

and

Warning: Trying to access array offset on value of type null in template_preprocess_views_view_datatables() (line 66 of /var/www/vhosts/dentaldirekt.de/dentaldirekt.de/web/modules/contrib/datatables/datatables.module).:

β§‰βŒ•array (46)

    ⇄⧉45: template_preprocess_views_view_datatables() => array (2)

    ⇄⧉44: call_user_func_array() => array (1)

    ⇄⧉43: Drupal\Core\Theme\ThemeManager->render() => array (2)

    ⇄⧉42: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉41: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉40: Drupal\Core\Render\Renderer->render() => array (2)

    ⇄⧉39: Drupal\Core\Template\TwigExtension->escapeFilter() => array (2)

    ⇄⧉38: __TwigTemplate_246c7880ec61d644e3ca38f7ed46c129->doDisplay() => array (2)

    ⇄⧉37: Twig\Template->displayWithErrorHandling() => array (2)

    ⇄⧉36: Twig\Template->display() => array (2)

    ⇄⧉35: Twig\Template->render() => array (2)

    ⇄⧉34: twig_render_template() => array (2)

    ⇄⧉33: Drupal\Core\Theme\ThemeManager->render() => array (2)

    ⇄⧉32: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉31: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉30: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉29: Drupal\Core\Render\Renderer->render() => array (2)

    ⇄⧉28: Drupal\Core\Template\TwigExtension->escapeFilter() => array (2)

    ⇄⧉27: __TwigTemplate_b3fb697e04e2fe18282f8c11c6b260a9->doDisplay() => array (2)

    ⇄⧉26: Twig\Template->displayWithErrorHandling() => array (2)

    ⇄⧉25: Twig\Template->display() => array (2)

    ⇄⧉24: Twig\Template->render() => array (2)

    ⇄⧉23: twig_render_template() => array (2)

    ⇄⧉22: Drupal\Core\Theme\ThemeManager->render() => array (2)

    ⇄⧉21: Drupal\Core\Render\Renderer->doRender() => array (2)

    ⇄⧉20: Drupal\Core\Render\Renderer->render() => array (2)

    ⇄⧉19: Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() => array (1)

    ⇄⧉18: Drupal\Core\Render\Renderer->executeInRenderContext() => array (2)

    ⇄⧉17: Drupal\Core\Render\MainContent\HtmlRenderer->prepare() => array (2)

    ⇄⧉16: Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() => array (2)

    ⇄⧉15: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() => array (2)

    ⇄⧉14: call_user_func() => array (1)

    ⇄⧉13: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() => array (2)

    ⇄⧉12: Symfony\Component\HttpKernel\HttpKernel->handleRaw() => array (2)

    ⇄⧉11: Symfony\Component\HttpKernel\HttpKernel->handle() => array (2)

    ⇄⧉10: Drupal\Core\StackMiddleware\Session->handle() => array (2)

    ⇄⧉ 9: Drupal\Core\StackMiddleware\KernelPreHandle->handle() => array (2)

    ⇄⧉ 8: Drupal\page_cache\StackMiddleware\PageCache->pass() => array (2)

    ⇄⧉ 7: Drupal\page_cache\StackMiddleware\PageCache->handle() => array (2)

    ⇄⧉ 6: Drupal\ban\BanMiddleware->handle() => array (2)

    ⇄⧉ 5: Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() => array (2)

    ⇄⧉ 4: Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() => array (2)

    ⇄⧉ 3: Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle() => array (2)

    ⇄⧉ 2: Stack\StackedHttpKernel->handle() => array (2)

    ⇄⧉ 1: Drupal\Core\DrupalKernel->handle() => array (2)

    ⇄⧉ 0: main() => array (2)

⧉ Called from <ROOT>/modules/contrib/datatables/datatables.module:66 [backtrace_error_handler()]

this is the affected line:

if($options['info'][$field]['empty_column'] && empty($variables['header'][$column])) {
        // This column is empty and was already removed. Don't do anything here.
        continue;
      }

Steps to reproduce

Proposed resolution

Change condition to
!empty($options['info'][$field]['empty_column'])
with the same boolean result but returning true, if a key doesn't exist.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

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

Merge Requests

Comments & Activities

  • Issue created by @Anybody
  • Status changed to Needs review over 1 year ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Here we go. This resolves the issue by adding a !empty() check.

  • πŸ‡«πŸ‡·France Chris64 France

    Well, in fact even if right the new code seems difficult to understand. Since if the column is empty then !empty is TRUE. And not clear for me what should be done if there is no information. For that point, may be let the next part to decide. That is !empty should return TRUE if there is no information, but it returns FALSE, since

    A variable is considered empty if it does not exist or if its value equals false.

    If the column is empty, then $options['info'][$field]['empty_column'] is TRUE, then empty($options['info'][$field]['empty_column']) is FALSE, then !empty is TRUE as expected. Ok, but difficult.
    In that conditions, what about this change?,
    $options['info'][$field]['empty_column']
    ->
    ($options['info'][$field]['empty_column'] ?? TRUE)
    If the information exists the existing information is returned, if not, the returned value is easily fixed.

    A second point. The information $options comes from,
    $options = $view->style_plugin->options;
    The issue tells the information does not exist. Is it normal? Or is there a problem with the view, or some thing between?

  • πŸ‡«πŸ‡·France Chris64 France

    @Anybody, may be a title shorter, would you like?

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States NicholasS

    The warning is about the $field key not being in the info array, so this change keeps the old logic, but remove the PHP warning since it won't try to access ['empty_column'] for a key that does not exist in the ['info'] array.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
  • Status changed to Needs work about 1 year ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @NicholasS your change is not wrong, but just obsolete. It just complicates the if clause with the same result:
    !empty($options['info'][$field]) && $options['info'][$field]['empty_column']
    is always the same!

    See #4.

    So that change should please be reverted. If the proposed MR works, we should take it as it was in the beginning. If you understand what empty() does, it's quite clear and always a clear boolean result!

  • Status changed to RTBC about 1 year ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thought about it again and for safety reasons let's do it as proposed. Thanks all!

  • πŸ‡«πŸ‡·France dqd London | N.Y.C | Paris | Hamburg | Berlin
  • Status changed to Fixed 10 months ago
  • πŸ‡«πŸ‡·France dqd London | N.Y.C | Paris | Hamburg | Berlin

    Thanks for all the work on this! comitted to latest dev 2.x

    +1 @Anybody, NicholasS, Chris64

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

Production build 0.71.5 2024