Introduced

Branch: 7.x-3.x
Release: 7.x-3.0

Policy

In Drupal 7+, all classes should be array of individual class strings.

This project is, in fact, following established guidelines for render array attribute classes:

https://drupal.org/update/modules/6/7#class_attribute_array
#326539: Convert 'class' attribute to use an array, not a string

Please find the offending module and file an issue in their issue queue to fix it.

CommentFileSizeAuthor
#11 edit_issue-2269653-1.patch624 bytesgollyg
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dqd’s picture

Issue summary: View changes
dqd’s picture

changing bootstrap/theme/system/image.vars.php

<?php
/**
 * Implements hook_preprocess_image().
 */
function bootstrap_preprocess_image(&$variables) {
  // Add image shape, if necessary.
  if ($shape = theme_get_setting('bootstrap_image_shape')) {
    $variables['attributes']['class'][] = $shape;
  }
  // Add responsiveness, if necessary.
  if ($shape = theme_get_setting('bootstrap_image_responsive')) {
    $variables['attributes']['class'][] = 'img-responsive';
  }
}
?>

to:

<?php
/**
 * Implements hook_preprocess_image().
 */
function bootstrap_preprocess_image(&$variables) {
  // Add image shape, if necessary.
  if ($shape = theme_get_setting('bootstrap_image_shape')) {
    $variables['attributes']['class'] = $shape;
  }
  // Add responsiveness, if necessary.
  if ($shape = theme_get_setting('bootstrap_image_responsive')) {
    $variables['attributes']['class'] = 'img-responsive';
  }
}
?>

... solved it. But this will overwrite the complete values regarding the key ['class'], not sure if this is wanted. Also I don't know why we have a double if here instead of an elseif ... Let me know what you think. Thanks ...

dqd’s picture

Status: Active » Needs review
dqd’s picture

Issue summary: View changes
dqd’s picture

Title: Bootstrap latest 7.x-dev causes WSOD » Bootstrap latest 7.x-3.x-dev causes WSOD, final release 3.0 not
dqd’s picture

Issue summary: View changes
markhalliwell’s picture

See the issue summary update above. I am making this issue the "go to" for this error.

markhalliwell’s picture

Title: Fatal error: [] operator not supported for strings in ./theme/system/image.vars.php » [policy][classes] Fatal error: [] operator not supported for strings
Issue summary: View changes
markhalliwell’s picture

Title: [policy][classes] Fatal error: [] operator not supported for strings » [bootstrap][policy][classes] Fatal error: [] operator not supported for strings
markhalliwell’s picture

Title: [bootstrap][policy][classes] Fatal error: [] operator not supported for strings » [bootstrap][policy] Classes - Fatal error: [] operator not supported for strings
gollyg’s picture

Status: Closed (won't fix) » Needs review
FileSize
624 bytes

I think that this may be an issue with the bootstrap textfield.func.php file.

It is calling drupal_attributes() early in the theming process. This function modifies the contents of the attribute array by referring to values by reference. This leads to the array structure changing. Later in the bootstrap function we are relying on the attribute array to be unchanged.

I have added a patch which creates a clone of the array, and passes the clone to the drupal_attributes function.

markhalliwell’s picture

Status: Needs review » Closed (won't fix)
  1. The patch in #11 isn't even related to this issue.
  2. drupal_array_merge_deep() is for merging multiple arrays, not to simpy typecast an empty string or NULL to an array. To get around that you'd just do something like:
      drupal_attributes((array)$element['#attributes'])
    
  3. Not trying to sound rude or dismissive, but please don't open closed (won't fix) issues, especially ones regarding policies for project... and for something that isn't even related.
markhalliwell’s picture

markhalliwell’s picture

Issue summary: View changes
Status: Closed (won't fix) » Closed (works as designed)
markhalliwell’s picture

Closing issue