tablePositionSticky should not be called on a non-array variable

Created on 6 February 2024, 6 months ago
Updated 22 April 2024, 3 months ago

Problem/Motivation

The Claro theme throws TypeError with a custom table block:
TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in in_array() (line 196 of /var/www/core/themes/claro/src/ClaroPreRender.php).

Steps to reproduce

  1. Enable Claro Theme as a default theme.
  2. Create a custom Block in a custom module to render a table with a class attribute as a string:
    class CustomBlock extends BlockBase
    {
      /**
       * {@inheritdoc}
       */
      public function build() {
        return [
          '#type' => 'table',
          '#attributes' => [
            'class' => 'classname'
          ]
        ];
      }
    }
  3. Place the block on the page.

Proposed resolution

Add a check to the tablePositionSticky method in the Claro theme to avoid calling the array function on a non-array variable.

Remaining tasks

  1. Review MR
  2. Commit
🐛 Bug report
Status

Fixed

Version

10.2

Component
Claro 

Last updated about 8 hours ago

Created by

🇺🇸United States ryanbuckley@gmail.com

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.69.0 2024