After I upgrade the php version form 5.5 to 7.1.3 I take a WSOD with message

Error: [] operator not supported for strings in shortcode_add_class()
(line 521 of ....../web/sites/all/modules/shortcode/shortcode.module).

After I patch the shortcode.module and add in line 521 the

+ $class = array();

Problem Solved...

Comments

TasosLo created an issue. See original summary.

tasoslo’s picture

Status: Active » Patch (to be ported)
youfei.sun’s picture

Version: 7.x-2.22 » 8.x-1.x-dev
Status: Patch (to be ported) » Needs review

For the 8.x branch, the same modification can be put on to line 195,
...
+ $classes = array();
$classes[] = $new_class;

at file src/Plugin/ShortcodeBase.php

Tonkers’s picture

Please include this fix for the next update of 7.x so our manual code revision won't be overridden. Just worried since it's been 6 months since the 7.x branch has been talked about. Thank you!

btweb’s picture

Hello
since no update yet of module , can someone explain where to add this line ?
function shortcode_add_class($class = '', $default = '') {
if ($class) {
if (!is_array($class)) {
$class = explode(' ', $class);
}
array_unshift($class, $default);
$class = array_unique($class);
}
else {
$class[] = $default;
}
return implode(' ', $class);
}
Thanks

denes.szabo’s picture

Assigned: Unassigned » denes.szabo

  • Denes.Szabo committed 73c26ba on 7.x-2.x
    Issue #2865906 by Denes.Szabo: Fix in class handling
    
  • Denes.Szabo committed b1f1a1d on 7.x-2.x
    Issue #2865906 by Denes.Szabo: Fix in basic_tags module + DCS fixes
    
denes.szabo’s picture

The Drupal 7 version fixed, just rolled out a new release 7.x-2.25.

I would appreciate if you could test this release with this bug.

I try to fix D8 version tomorrow.

denes.szabo’s picture

Fixed. Would you mind to check it?

gmclelland’s picture

Looks like I'm still running into this error with 7.x-2.26. See #3014037: Error: [] operator not supported for strings in shortcode_add_class()

Anybody have any ideas for a fix?

gmclelland’s picture

Sorry for the noise. It was an error on my part. Disregard my comment.

denes.szabo’s picture

Status: Needs review » Fixed
denes.szabo’s picture

Status: Fixed » Closed (fixed)
liam morland’s picture

Issue tags: -php7.1 +PHP 7.1
denes.szabo’s picture