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

Comments

cqbent created an issue. See original summary.

hatuhay’s picture

Issue summary: View changes
Status: Active » Needs review
Related issues: +#3031270: Undefined index: class in bootstrap_barrio_preprocess_html()

The 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

guaneagler’s picture

StatusFileSize
new602 bytes

Just 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.

Status: Needs review » Needs work

The last submitted patch, 3: 3032435-remove-code-delete-body-class.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

hatuhay’s picture

Patch in #3, will only drive into inconsistency errors.
The $variables['attributes']['class'] must be tested and initialized if do not exist.

cqbent’s picture

StatusFileSize
new478 bytes

Here's the patch I created for fixing this issue by replacing the !is_array || !array_key_exists with the more generic !isset

  • hatuhay committed 081ccb0 on 8.x-4.x authored by cqbent
    Issue #3032435 by cqbent, guaneagler: The...
weynhamz’s picture

StatusFileSize
new450 bytes

Upload patch for the accepted commit.

morbus iff’s picture

Status: Needs work » Fixed

This looks like it's been committed, so setting to Fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.