PHP Fatal error: [] operator not supported for strings in panopoly_images/panopoly_images.module on line 90

$variables['attributes']['class'][] = str_replace('_', '-', $variables['style_name']);

"$variables['attributes']['class']" is a string.

my fix:

/*
  https://drupal.org/node/1722146
   The class attributes is a string, but drupal requires it to be
   an array, so we fix it here.
   $tag_info['attributes']['class'] = explode(" ", $tag_info['attributes']['class']);
*/
 $variables['attributes']['class'] = explode(" ", $variables['attributes']['class']);
 $variables['attributes']['class'][] = str_replace('_', '-', $variables['style_name']);
CommentFileSizeAuthor
#8 2181263-misused-class-attribute.patch697 bytesAnonymous (not verified)

Comments

mglaman’s picture

Status: Active » Postponed (maintainer needs more info)
Related issues: +#1722146: Media filter is using string instead of array for the class attribute

SocialNicheGuru, can you help explain how to replicate the error? I understand the process, but would be beneficial to pinpoint replication and test.

mglaman’s picture

SocialNicheGuru, after investigation it appears that the issue is there is a module setting $variables['attributes']['class'] as a string, not as an array.

Your fix provides a healing method, but provides a bandaid to a bug somewhere else. If you help provide steps to reproduce and any related modules we can get this sorted out!

socialnicheguru’s picture

thanks.

I'll try to find the module and report back (debug_backtrace() here I come.

any tips on howto debug would be great.

lsolesen’s picture

dsnopek’s picture

Component: Admin » Images
jpstrikesback’s picture

image_class is one module that doesn't play nicely.

dsnopek’s picture

Status: Postponed (maintainer needs more info) » Active

Given that there are a number of modules in the wild that treat this as a string (rather than array), I think we should patch panopoly_images to deal with that case. This follows the "Robustness principle":

Be conservative in what you do, be liberal in what you accept from others

http://en.wikipedia.org/wiki/Robustness_principle

Anonymous’s picture

StatusFileSize
new697 bytes

You meant something like this?

  • dsnopek committed a46a786 on 7.x-1.x
    Update Panopoly Images for Issue #2181263 by ivanjaros: HP Fatal error...
dsnopek’s picture

Status: Active » Fixed

Thanks, that's exactly what I meant! :-) Committed.

Status: Fixed » Closed (fixed)

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