- Issue created by @chsdaiguil
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
Active
6.0
Code