Problem/Motivation
Certain URL's such as admin/structure/block return unexpected errors due to PHP TypeError's in function preprocessAggregatorContainer of zeropoint/src/Hook/ZeropointHooks.php.
Steps to reproduce
On Drupal 11.4.9, navigate to https://example.com/admin/structure/block.
The client shows: "The website encountered an unexpected error. Try again later."
Watchdog reports:
24366 13/Oct 23:01 php Error TypeError: in_array(): Argument #2 ($haystack) must be of type
array, string given in in_array() (line 1221 of
/var/www/drupal/themes/contrib/zeropoint/src/Hook/ZeropointHooks.p
hp).
Proposed resolution
Cast to an array when assigning classes.
$classes = (array) ($variables['element']['#attributes']['class'] ?? []);
(...or track down the guilty party who put a singleton object in there, and convince them to repent of the evil of their ways.)
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork zeropoint-3630998
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
adityarawat_ln commentedComment #4
adityarawat_ln commentedI reproduced the reported TypeError on Drupal 11.4.9 using the Zero Point 2.0.0 theme.
I updated `preprocessAggregatorContainer()` in `ZeropointHooks.php` to cast the class attribute to an array before passing it to `in_array()`.
After clearing Drupal's cache, I verified that `/admin/structure/block` loads without the reported TypeError.
I've opened a merge request targeting the `2.0.x` branch with the fix for review:
Comment #6
florian commentedThanks @adityarawat_ln,
The bug was fixed in 2.0.1 release.
Comment #8
florian commentedComment #9
florian commented