Author Topic: 0 [] operator not supported for strings when selecting configuration option  (Read 4444 times)

nsar

  • Beginner
  • *
  • Posts: 3
  • A beginner
  • Skype Name: nsar68
when i select configuration option all i get is 0 [] operator not supported for strings

is there a solution for that problem

thank you

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26372
  • Always on vacation
    • Jenkin Hill Internet
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM3.2.6 on Joomla 3.8.2 PHP 7.0.25

Testing VM3.2.6 on J!4alpha1

reinhold

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 204
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:
  • Log in to the Joomla backend
  • Go to Virtuemart -> Configuration -> Configuration
  • The error is shown:
Code: [Select]
"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:

Quote
Call 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...

reinhold

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 204
I found the culprit: in the config model, function getNoImageList was the following code:
Code: [Select]
       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:
Code: [Select]
$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

Tiger78

  • Beginner
  • *
  • Posts: 16
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


GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7621
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.2
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
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9382
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
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.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

RobertL

  • Beginner
  • *
  • Posts: 43
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

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9382
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
I need the lines,.. the trace, something to find it. A bit more than "trying to view the shopping cart" would be nice.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

RobertL

  • Beginner
  • *
  • Posts: 43
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.

HenrikS

  • Beginner
  • *
  • Posts: 16
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

HenrikS

  • Beginner
  • *
  • Posts: 16
PHP 7.1.4 on PHP 7.0.18 there is no problem

HenrikS

  • Beginner
  • *
  • Posts: 16
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