The bootstrap_barrio_preprocess_html function is stripping out $variables['attributes']['class'] variables even though they exist in some cases.
I think this is happening when the $variables['attributes']['class'] is an object containing an array instead of an array itself. This is causing problems for me specifically with the imce module file browser page where the imce-page class is getting stripped out which prevents the javascript from loading. I fixed this locally by replacing the !is_array || !array_key_exists with the more generic !isset. Seems to work fine now. Is there any reason not to use !isset instead?
https://www.drupal.org/project/bootstrap_barrio/issues/3031270
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3032435-8.patch | 450 bytes | weynhamz |
| #6 | bootstrap_barrio_preprocess_html_fix.patch | 478 bytes | cqbent |
| #3 | 3032435-remove-code-delete-body-class.patch | 602 bytes | guaneagler |
Comments
Comment #2
hatuhay commentedThe code was updated with this issue.
Undefined index: class in bootstrap_barrio_preprocess_html() (3031270)
If you can confirm your solution and provide a patch I will me more than happy to commit
Comment #3
guaneagler commentedJust remove the code this patch added.
For the $variables['attributes'], it may be an array or a object of 'Drupal\Core\Template\Attribute'. Both can set class by access $variables['attributes']['class'].
For my site, $variables['attributes'] is an array when is not logged in and is an object when is logged in.
Comment #5
hatuhay commentedPatch in #3, will only drive into inconsistency errors.
The $variables['attributes']['class'] must be tested and initialized if do not exist.
Comment #6
cqbent commentedHere's the patch I created for fixing this issue by replacing the !is_array || !array_key_exists with the more generic !isset
Comment #8
weynhamzUpload patch for the accepted commit.
Comment #9
morbus iffThis looks like it's been committed, so setting to Fixed.