: Bug in dxpr_theme.theme with theme_get_setting('block_design_regions') in Multisite Context

Created on 23 May 2025, 2 months ago

Dear Maintainer,
We are using dxpr_theme (version 6.0.4) in a Drupal multisite environment with two sub-themes (fs_dxpr_theme and dxpr_lesplebeiens_theme). We encountered a fatal error in dxpr_theme.theme at line 308, within the dxpr_theme_preprocess_region() function:
Error:

TypeError: array_filter(): Argument #1 ($array) must be of type array, null given

Problematic Code (dxpr_theme.theme, line 304):

if ($block_design_regions = array_keys(array_filter(theme_get_setting('block_design_regions')))) {
  if (in_array($variables['region'], $block_design_regions)) {
    $variables['attributes']['class'][] = 'region-block-design';
  }
}

Cause:
In a multisite setup, theme_get_setting('block_design_regions') may return null if the setting is not defined for a sub-theme, causing the TypeError when array_filter() attempts to process null.
Applied Fix:
We modified the code to handle this case:

$block_design_regions = theme_get_setting('block_design_regions') ? array_keys(array_filter(theme_get_setting('block_design_regions'))) : [];
if (in_array($variables['region'], $block_design_regions)) {
  $variables['attributes']['class'][] = 'region-block-design';
}

Suggestion:
To prevent this issue in future releases, we recommend adding an explicit check to ensure theme_get_setting('block_design_regions') is an array before calling array_filter(). A more robust solution could be:

$block_design_regions = is_array(theme_get_setting('block_design_regions')) ? array_keys(array_filter(theme_get_setting('block_design_regions'))) : [];
if (in_array($variables['region'], $block_design_regions)) {
  $variables['attributes']['class'][] = 'region-block-design';
}

Context:
Environment: Drupal multisite (version 9.4 or higher).

Parent theme: dxpr_theme 6.0.4.

Sub-themes: fs_dxpr_theme, dxpr_lesplebeiens_theme.

Related modules: dxpr_theme_helper, file, media_library_form_element.

This fix resolved the error for our sub-themes, but we believe it should be incorporated into the theme to prevent similar issues for other users, especially in multisite configurations.
Thank you for your work on dxpr_theme. Please feel free to reach out if you need additional information or further testing.
Best regards,
Grok
Site: https://lesplebeiens.fr

🐛 Bug report
Status

Active

Version

6.0

Component

Code

Created by

🇫🇷France chsdaiguil Coteaux-du-lyonnais

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

Comments & Activities

Production build 0.71.5 2024