Summary
Issue https://www.drupal.org/project/dxpr_theme/issues/3570233
On some Drupal 10 / PHP 8+ sites upgrading from DXPR Theme 1.x to 8.x, PHP throws a TypeError in dxpr_theme.theme when certain theme settings (e.g. block design / hidden regions) are not set. It looks like theme_get_setting() can return null, and that value is passed directly into array_filter().
Steps to reproduce
- Start from a Drupal 10 site with:
- PHP 8.3
- dxpr_theme 1.x installed and set as the default theme
- Configure theme settings (including block / region related options).
- Upgrade to dxpr_theme 8.x using Composer, e.g.:
- composer require drupal/bootstrap5
- Enable Bootstrap 5 in the UI (/admin/appearance).
- composer require 'drupal/dxpr_theme:^8' -w
- Run database updates and clear caches:
drush updb -y
drush cr
- Visit a frontend page that renders blocks in regions covered by DXPR’s block design settings.
Note: I have not been able to reliably reproduce the error myself, but another user reported it with this stack trace and pointed to dxpr_theme.theme around the block design / hidden region handling.
What is the current bug behavior?
On some configurations, after the upgrade:
- PHP 8+ throws something like:
TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() in themes/contrib/dxpr_theme/dxpr_theme.theme on/around line 435
The reporter indicated this happens when rendering regions where DXPR’s block design settings apply.
What is the expected correct behavior?
- Theme pages should render without PHP fatals, even when certain theme settings have never been set.
- If a setting is missing, the theme should simply skip applying the related CSS classes / logic, instead of throwing a TypeError.
Relevant logs and/or screenshots
Example error (from another user’s local environment, paraphrased):
TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 435 of themes/contrib/dxpr_theme/dxpr_theme.theme) #0 themes/contrib/dxpr_theme/dxpr_theme.theme(435): array_filter(NULL) ...
This points at the code that reads theme_get_setting('block_design_regions') and passes it to array_filter().
Possible fixes
At a high level, the issue seems to be that:
theme_get_setting('block_design_regions') and theme_get_setting('hidden_regions') can return null under some configurations.
- That value is then used directly in
array_filter() (and array_keys(array_filter(...))), which is not allowed in PHP 8+.
A possible direction for a fix would be to:
- Add a simple type check (e.g.
is_array(...)) or a default empty array before passing these values into array_filter().
- Apply this guard in the places where
dxpr_theme.theme uses theme_get_setting('block_design_regions') and theme_get_setting('hidden_regions') to build lists of regions and apply classes.
I already have a small patch on Drupal.org’s issue [#3570233] that adds this kind of guard, and it has been tested locally by both me and the original reporter. If helpful, I can adapt that patch into a GitHub PR against the 8.x branch.
Summary
Issue https://www.drupal.org/project/dxpr_theme/issues/3570233
On some Drupal 10 / PHP 8+ sites upgrading from DXPR Theme 1.x to 8.x, PHP throws a TypeError in dxpr_theme.theme when certain theme settings (e.g. block design / hidden regions) are not set. It looks like theme_get_setting() can return null, and that value is passed directly into array_filter().
Steps to reproduce
drush updb -ydrush crNote: I have not been able to reliably reproduce the error myself, but another user reported it with this stack trace and pointed to dxpr_theme.theme around the block design / hidden region handling.
What is the current bug behavior?
On some configurations, after the upgrade:
TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() in themes/contrib/dxpr_theme/dxpr_theme.theme on/around line 435The reporter indicated this happens when rendering regions where DXPR’s block design settings apply.
What is the expected correct behavior?
Relevant logs and/or screenshots
Example error (from another user’s local environment, paraphrased):
TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 435 of themes/contrib/dxpr_theme/dxpr_theme.theme) #0 themes/contrib/dxpr_theme/dxpr_theme.theme(435): array_filter(NULL) ...This points at the code that reads
theme_get_setting('block_design_regions')and passes it toarray_filter().Possible fixes
At a high level, the issue seems to be that:
theme_get_setting('block_design_regions')andtheme_get_setting('hidden_regions')can returnnullunder some configurations.array_filter()(andarray_keys(array_filter(...))), which is not allowed in PHP 8+.A possible direction for a fix would be to:
is_array(...)) or a default empty array before passing these values intoarray_filter().dxpr_theme.themeusestheme_get_setting('block_design_regions')and theme_get_setting('hidden_regions')to build lists of regions and apply classes.I already have a small patch on Drupal.org’s issue [#3570233] that adds this kind of guard, and it has been tested locally by both me and the original reporter. If helpful, I can adapt that patch into a GitHub PR against the 8.x branch.