PHP message: PHP Fatal error: [] operator not supported for strings in sites/all/themes/mbase/includes/helper.inc on line 1577

Original code

$link['attributes']['class'][] = 'btn'; // row 1577 crashes due to not initialised as array
$link['attributes']['class'][] = 'btn-xs';

Quickfix
$link['attributes']['class'] = array($link['attributes']['class'],'btn');
$link['attributes']['class'][] = 'btn-xs';

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

arne_hortell created an issue. See original summary.

arne_hortell’s picture

It also requires to check IF ['class'] exists...

pifagor’s picture

FileSize
600 bytes

implemented in patch

pifagor’s picture

Status: Active » Needs review
arne_hortell’s picture

// with no check if 'class' exists it gives notice message...
// creates typecasting if $link['attributes']['class'] is defined but is a string
if (array_key_exists('class',$link['attributes']))
$link['attributes']['class'] = array($link['attributes']['class'],'btn');
else
$link['attributes'][] = array('class'=>'btn');

arne_hortell’s picture

More fixinig needed for mbase

Row 78 and forward should be

function _mbase_smart_region(&$var, $regions, $theme) {
foreach ($regions as $region) {
$drupal_block=false; // added by me
if (array_key_exists($region,$var['page'])) // added by me
$drupal_block = $var['page'][$region];
// Display the block if it exists.

pifagor’s picture

FileSize
1.19 KB

@arne_hortell thank you for the advice. New patch

pifagor’s picture

FileSize
1.19 KB

Fixed on coding standards