VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: nsar on December 16, 2016, 12:58:11 PM

Title: 0 [] operator not supported for strings when selecting configuration option
Post by: nsar on December 16, 2016, 12:58:11 PM
when i select configuration option all i get is 0 [] operator not supported for strings

is there a solution for that problem

thank you
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: jenkinhill on December 16, 2016, 13:34:09 PM
??  http://forum.virtuemart.net/index.php?topic=104795.0
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: reinhold on December 18, 2016, 16:53:22 PM
Same issue here with a fresh installation (full installer with VM3.0.17.8 on Joomla 3.6.2 => updated to VM 3.0.18 and Joomla 3.6.5 through Joomla's update manager).

PHP Version is 7.1, using docker's php7.1-apache image (Debian jessie-based).

Steps to reproduce:
"An error has occurred.
0 [] operator not supported for strings
Return to Control Panel"


I could not find anything in the Apache server logs or the VM logs in administrator/logs/.

The VM backend works in general, just the configuration page throws this error.

Best regards,
Reinhold

PS: If I enable "Debug System" in the Joomla config, then I get a backtrace:

QuoteCall stack
#   Function   Location
1   JApplicationCms->execute()   /var/www/html/administrator/index.php:51
2   JApplicationAdministrator->doExecute()   /var/www/html/libraries/cms/application/cms.php:261
3   JApplicationAdministrator->dispatch()   /var/www/html/libraries/cms/application/administrator.php:152
4   JComponentHelper::renderComponent()   /var/www/html/libraries/cms/application/administrator.php:98
5   JComponentHelper::executeComponent()   /var/www/html/libraries/cms/component/helper.php:380
6   require_once()   /var/www/html/libraries/cms/component/helper.php:405
7   JControllerLegacy->execute()   /var/www/html/administrator/components/com_virtuemart/virtuemart.php:78
8   VmController->display()   /var/www/html/libraries/legacy/controller/legacy.php:702
9   VirtuemartViewConfig->display()   /var/www/html/administrator/components/com_virtuemart/helpers/vmcontroller.php:122
10   VirtueMartModelConfig->getNoImageList()   /var/www/html/administrator/components/com_virtuemart/views/config/view.html.php:70
Comenting out the line 70 ($this->noimagelist = $model->getNoImageList(); ) and the line with currConverterList makes the configuration page load, but of course discards these two settings...
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: reinhold on December 18, 2016, 17:09:13 PM
I found the culprit: in the config model, function getNoImageList was the following code:

       function getNoImageList() {
[...]
                $result = '';

                foreach($dirs as $dir){
                        if ($handle = opendir($dir)) {
                                while (false !== ($file = readdir($handle))) {
                                        if ($file != "." && $file != ".." && $file != '.svn' && $file != 'index.html') {
                                                if (filetype($dir.DS.$file) != 'dir') {
                                                        $result[] = JHtml::_('select.option', $file, vmText::_(str_replace('.php', '', $file)));
                                                }                                                                                                                                                                                                           
                                        }                                                                                                                                                                                                                   
                                }                                                                                                                                                                                                                           
                        }                                                                                                                                                                                                                                   
                }                                                                                                                                                                                                                                           
                return $result;                                                                                                                                                                                                                             
        }                                                                                                                                                                                                                                                   


The problem is that $result is set to an empty string and then appended to it like it was an array. Simply change line 208 to:

$result = array();

and a similar change to getCurrencyConverterList (line 233) in administrator/components/com_virtuemart/models/config.php and everything works.

This needs to be fixed in the VM core code by the VM developers.

Best regards,
Reinhold
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: Tiger78 on December 25, 2016, 16:16:16 PM
I´ve had the same error after switching PHP from 7.0.14 to 7.1.0.

After the core hacks, virtuemart works fine.
Thanks!


VM 3.0.18 / Joomla 3.6.5 / PHP 7.1.0

Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: GJC Web Design on December 31, 2016, 16:55:20 PM
Can confirm these changes fix the problem of VM config 3.0.18  on php7.1.0

//$result = '';
      $result = array();

2 x on lines  208 & 235
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: Milbo on January 02, 2017, 18:06:08 PM
Thank you for finding the culprit, I am sure there are more problems like this. Because it is a standard pattern, which worked from php5.3 -php7.0, seems that php7.1 breaks this quickndirty pattern.

The problem is that, it may need another line in the function calling getNoImageList to prevent problems in lower php versions.
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: RobertL on May 03, 2017, 12:03:27 PM
Found the same issue on a new build when trying to view the shopping cart in the front end on PHP7.1.4 (works fine on 7.0.18).

J3.6.5 and 3.7.0, VM 3.2.1, PHP 7.1
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: Milbo on May 03, 2017, 13:02:43 PM
I need the lines,.. the trace, something to find it. A bit more than "trying to view the shopping cart" would be nice.
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: RobertL on May 03, 2017, 17:13:31 PM
That would be handy, yes sorry. I'll try again to get to them. Was nothing in the logs on the server or in admin logs.

edit: will try again over the weekend Milbo, release date is in a few days so must finish on PHP 7.0 and fork it to sort the issue.
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: HenrikS on May 19, 2017, 20:21:17 PM
Got this one in adminpanel when i try to disable shopperfields

0 Too few arguments to function VmController::toggle(), 0 passed in /home/***/***/libraries/legacy/controller/legacy.php on line 709 and at least 1 expected
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: HenrikS on May 19, 2017, 20:22:44 PM
PHP 7.1.4 on PHP 7.0.18 there is no problem
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: HenrikS on May 19, 2017, 20:28:32 PM
An error has occurred.
0 Too few arguments to function VmController::toggle(), 0 passed in /home/***/***/libraries/legacy/controller/legacy.php on line 709 and at least 1 expected
Call stack
#   Function   Location
1   VmController->toggle()   JROOT/libraries/legacy/controller/legacy.php:709
2   JControllerLegacy->execute()   JROOT/administrator/components/com_virtuemart/virtuemart.php:76
3   require_once()   JROOT/libraries/cms/component/helper.php:394
4   JComponentHelper::executeComponent()   JROOT/libraries/cms/component/helper.php:369
5   JComponentHelper::renderComponent()   JROOT/libraries/cms/application/administrator.php:98
6   JApplicationAdministrator->dispatch()   JROOT/libraries/cms/application/administrator.php:156
7   JApplicationAdministrator->doExecute()   JROOT/libraries/cms/application/cms.php:265
8   JApplicationCms->execute()   JROOT/administrator/index.php:51
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: jankoo on April 29, 2019, 17:08:49 PM
is this still issue? i got this error on php 7.3 and latest vm 3.4.2
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: jenkinhill on April 29, 2019, 17:48:34 PM
Some people have reported problems with PHP7.3 so it is advised to use no later than 7.2 currently.
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: jankoo on May 14, 2019, 07:56:45 AM
Quote from: jenkinhill on April 29, 2019, 17:48:34 PM
Some people have reported problems with PHP7.3 so it is advised to use no later than 7.2 currently.

ok.. now i have it also on php 7.2.13.. so what version should i use?
it wont be fixed for all?
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: jenkinhill on May 14, 2019, 11:24:33 AM
7.2 is fine.
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: jankoo on May 14, 2019, 13:30:48 PM
Quote from: jenkinhill on May 14, 2019, 11:24:33 AM
7.2 is fine.

i dont have this option on hosting.. on none of the php versions i cant open the settings  :'(
i can have 7.1.25, 7.2.13 or 7.3.0

what i can do? why important thing as this still dont work.. its issue from 2016?
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: GJC Web Design on May 14, 2019, 13:39:24 PM
7.2.13 ==  7.2

they are sub versions

If u want the  0 [] operator not supported for strings fixed u need to do the research to find WHERE this is being thrown .. most of my sites are on php 7.3 and I haven't seen this error since all ( most? ) were found months ago
could just as easily be in a 3rd party plugin etc etc
Title: Re: 0 [] operator not supported for strings when selecting configuration option
Post by: Milbo on May 15, 2019, 16:45:55 PM
Meanwhile it should also run on php7.3, if there are good bug reports, we can provide a fix. But the current main php version is php 7.2