WSOD on node revision page

Created on 6 July 2023, over 1 year ago
Updated 26 November 2023, about 1 year ago

Problem/Motivation

Gin's table preprocessing results in a WSOD on the node revision page.

Code in table.theme:

function gin_theme_suggestions_table_alter(array &$suggestions, array $variables): void {
  if (isset($variables['attributes']['class']) && in_array('field-multiple-table', $variables['attributes']['class'])) {
    $suggestions[] = 'table__simple';
  }
}

But $variables['attributes']['class'] is a string value "node-revision-table".

But I'm not even sure if this is a bug by Gin or a bug of Drupal core. Is there a rule that $attributes['class'] must be an array?

Steps to reproduce

Visit the revision page of any node /node/NODE_ID/revisions

Proposed resolution

function gin_theme_suggestions_table_alter(array &$suggestions, array $variables): void {
  if (empty($variables['attributes']['class'])) {
    return;
  }
  // Untested, but did traversable check so it doesn't die again if somebody uses an Attribute object
  if (!($variables['attributes']['class'] instanceof \Traversable)) {
    $variables['attributes']['class'] = [$variables['attributes']['class']];
  }
  if (in_array('field-multiple-table', $variables['attributes']['class'])) {
    $suggestions[] = 'table__simple';
  }
}

Remaining tasks

Decide if this needs a fix here or in Core

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria hudri Austria

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

Comments & Activities

Production build 0.71.5 2024