Fatal error: [] operator not supported for strings

Bauer

Well-Known Member
I just started getting this fatal error in form.php - using php 7.1.3. (See attachment)

Line 4900 is...
PHP:
$group->class[] = 'fabrikGroup';
the variable $group is initialized on line 4741 as...
PHP:
$group = $groupModel->getGroupProperties($this);
which returns an object (that does not include [class]).

Initially, I assumed an easy fix for this particular "[] operator not supported for strings" error would be to just change line 4700 to...
PHP:
$group->class = array('fabrikGroup');
But I'm not sure if 'class' might sometimes already be included in the getGroupProperties - and if so would it be included as a string or an array? And might that string be a space-delimited list of class names?

In that case, replacing line 4700 with something like this should cover it all...
PHP:
if(!is_array($group->class)) {
   $group->class = (isset($group->class)) ? explode(' ',$group->class) : array();
}
$group->class[] = 'fabrikGroup';

Because of my uncertainties, I won't try to fix this at Github myself - I'm just the messenger.
But that suggested code is now working for me.
 

Attachments

  • fatalError.png
    fatalError.png
    43.3 KB · Views: 37
Last edited:
I just committed a fix.

Weird that my PHP 7.1.8 doesn't throw that.

-- hugh
It was a test user who found this just yesterday.
I was initially confused by the error too, because I know I had used that menu link in the recent past.

I just did a little research in my email notices for the nightly CRON and my site was just updated to php 7.1.9 on 2017-09-22.
Once the site goes public, I'm going to have to stop my host provider from automatically updating php because incidents like this would not be tolerated if we were 'live'.

Now the question is, where else in the Fabrik code might something like that be used? I suppose we'll soon find out.
I'm not sure I agree with throwing the fatal error but I suppose they had good reason to do so.

Anyhow, thanks for the quick response!:)
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top