VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: cmvrgr on July 24, 2019, 15:45:39 PM

Title: [] operator not supported for strings when visiting the basket php 7.1
Post by: cmvrgr on July 24, 2019, 15:45:39 PM
Hi, I am using  Joomla 3.9 and  VirtueMart 3.4.2 and I am using PHP PHP 7.0.33. Joomla displayed a message that I have to switch to a newer version for security reasons.

My hosting provider supports PHP 7.1.30, PHP 7.2.20, PHP 7.3.7. The major problem that exists is that when I am switching in either of the newer versions when I am visiting the shopping card I am getting an error message  "[] operator not supported for strings".

Is there a workaround to fix that?

Thanks
Title: Re: [] operator not supported for strings when visiting the basket php 7.1
Post by: Jörgen on July 24, 2019, 16:07:38 PM
Is it an error ? Or is it a warning?
Turn down error reporting. What extension gives the message?
Jörgen @ Kreativ Fotografi
Title: Re: [] operator not supported for strings when visiting the basket php 7.1
Post by: cmvrgr on August 07, 2019, 15:35:10 PM
That message appears when going to cart. when switching back to the older unsuported PHP 7.0.33 it works fine.

[] operator not supported for strings

If problems persist, please contact the administrator of this site and report the error below

[] operator not supported for strings
Title: Re: [] operator not supported for strings when visiting the basket php 7.1
Post by: StefanSTS on August 07, 2019, 16:01:01 PM
Are you using any special extensions for the cart?
Title: Re: [] operator not supported for strings when visiting the basket php 7.1
Post by: cmvrgr on August 07, 2019, 16:07:15 PM
No I am not. I tried also other template and also I have Layout Bootstrap version to None(legacy).

This is realy crazy. When moving to newer PHP PHP 7.1.30,    PHP 7.2.20,    PHP 7.3.7 stops working and get the operator not supported for stings message.

Only at PHP 7.0.33 works but joomla displays a message that this version is not supported by the creators and need to update to newer version.
Title: Re: [] operator not supported for strings when visiting the basket php 7.1
Post by: GJC Web Design on August 07, 2019, 16:17:25 PM
you need to trace what is causing this error

plenty of info here:   http://forum.virtuemart.net/index.php?topic=117042.0
Title: Re: [] operator not supported for strings when visiting the basket php 7.1
Post by: cmvrgr on August 07, 2019, 16:20:36 PM
Thanks for the info

My template is Horme 3 free.
Title: Re: [] operator not supported for strings when visiting the basket php 7.1
Post by: jjk on August 07, 2019, 19:32:40 PM
I suppose the problem is this: https://www.php.net/manual/en/language.types.array.php
Creating/modifying with square bracket syntax ¶

An existing array can be modified by explicitly setting values in it.

This is done by assigning values to the array, specifying the key in brackets. The key can also be omitted, resulting in an empty pair of brackets ([]).

$arr[key] = value;
$arr[] = value;
// key may be an integer or string
// value may be any value of any type


If $arr doesn't exist yet, it will be created, so this is also an alternative way to create an array. This practice is however discouraged because if $arr already contains some value (e.g. string from request variable) then this value will stay in the place and [] may actually stand for string access operator. It is always better to initialize a variable by a direct assignment.

    Note: As of PHP 7.1.0, applying the empty index operator on a string throws a fatal error. Formerly, the string was silently converted to an array.
Title: Re: [] operator not supported for strings when visiting the basket php 7.1
Post by: GJC Web Design on August 08, 2019, 15:26:21 PM
but he still needs to trace WHERE this is being called...