Post by Ihorius » Tue Mar 17, 2015 2:27 am

Hello,
I have a problem and I think it's a bug. As on the server so even locally, when I enter in the administration area and I'm going to change a Customer (route=sale/customer/edit), the tabs appear on the page like History, Transactions, IP addresses, etc... not working! On the top, is open the General tab, with all the information of the Customer written right, but if I try to change the tab, nothing happens, the customer data remain the same as if I still on the General tab.
Can you tell me how to solve the problem?
My server run on PHP 5.3.29, I test the problem under 5.2.x and 5.5.x, same results ???

Newbie

Posts

Joined
Mon Mar 16, 2015 10:17 pm

Post by Ihorius » Tue Mar 17, 2015 11:02 pm

Ok, I solved alone.
I explain below the matter, maybe for someone will be useful, because actually it is a bug in OpenCart 2.0.1.1.

Reproduce the bug:
Create a text Custom Field in the Address section.

How bug works:
On the page route=sale/customer/edit occurs an "Fatal error: Cannot use string offset as an array".

The tabs of which I speak in the previous post don't work precisely because this bug generates an Fatal error and the page is returned to the browser without being complete!

This error is generated by the various lines of code that throw an error in View when an error occurs on the Custom Field. More precisely, the instruction that generates the error is the following:
if (isset($error_address [$address_row]['custom_field'][$custom_field['custom_field_id']])) { ...
in admin/view/template/sale/custom_form.tpl.

The error is generated because the variable $error_address (without any Custom Field error to be displayed) is set, in the admin/controller/sale/customer.php file, to "", that is, to an empty string (string (0)) and not to an array.
When the IF condition above is evaluated, is precisely generate the error above because cannot use string offset as an array.

Here you can find more information about this error:
http://stackoverflow.com/questions/1873 ... ray-in-php
http://informationideas.com/news/2006/0 ... nt-page-2/

Bug fix / Workaround:
The solution then is quite simple, that is, change the declaration of the variable $error_address in the file admin/controller/sale/customer.php from $error_address = ""; to $error_address = array (); in this way the error will not occur anymore.

I hope that this solution can help someone who has been confronted with the same error and maybe for the OpenCart developers to fix this bug in the next version.

I attach the XML script for vqmod for anyone who wants fix the bug quickly or study it better.

Regards ;)

Newbie

Posts

Joined
Mon Mar 16, 2015 10:17 pm
Who is online

Users browsing this forum: No registered users and 10 guests