TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 580 of modules/contrib/gin_lb/gin_lb.module)

Created on 1 September 2021, almost 3 years ago
Updated 9 July 2023, 12 months ago

In some cases (for example if I go to edit a text format) this module will throw the error noted in the title:

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 580 of modules/contrib/gin_lb/gin_lb.module)

This line of code here assumes that there is a class element of the attributes array:

  if (in_array('glb-table', $variables['attributes']['class'], TRUE)) {

The simple fix:

  if (!empty($variables['attributes']['class']) && in_array('glb-table', $variables['attributes']['class'], TRUE)) {

I will attach a patch shortly.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada teknocat

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States Chris Matthews

    I do not have Gin Layout Builder enabled, but I'm getting a similar error when trying to access the Revisions tab on any node/content type.

    TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in in_array() (line 12 of themes/contrib/gin/includes/table.theme).
    
    gin_theme_suggestions_table_alter(Array, Array, 'table') (Line: 435)
    Drupal\Core\Theme\ThemeManager->alterForTheme(Object, 'theme_suggestions', Array, Array, 'table') (Line: 444)
    Drupal\Core\Theme\ThemeManager->alter(Array, Array, Array, 'table') (Line: 244)
    Drupal\Core\Theme\ThemeManager->render('table', Array) (Line: 436)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 449)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 583)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
    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: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 171)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
    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: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
    Drupal\ban\BanMiddleware->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: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
Production build 0.69.0 2024