When I set my web server to use php 5.4 or 5.5, I will see the error below when I press the save button on
Home » Administration » Store » Configuration » Countries and addresses
i.e. http://yourdomain.com/#overlay=admin/store/settings/countries/formats

Warning: Illegal string offset 'address_format' in uc_country_formats_form_submit() (line 191 of /public_html/sites/all/modules/ubercart/uc_store/uc_store.countries.inc).

There is no such error when the server is set to php 5.3

CommentFileSizeAuthor
#5 2597009-5-php-warning.patch1.42 KBtr

Comments

ericwongcm created an issue. See original summary.

ericwongcm’s picture

Issue summary: View changes
tr’s picture

Which countries do you have enabled?

ericwongcm’s picture

What country is enabled does not matter..

The error remains if I remove all the countries..

tr’s picture

Status: Active » Needs review
StatusFileSize
new1.42 KB

Try this ...

ericwongcm’s picture

With the patch applied the error is gone using php 5.3, 5.4 and 5.5.

  • TR committed b42bfe4 on 7.x-3.x
    Issue [#2597009]: Warning when saving address format in PHP 5.5.
    
tr’s picture

Status: Needs review » Fixed

Thanks for testing it. Committed.

ericwongcm’s picture

Status: Fixed » Needs work

Please revert the patch and maybe revise it.

I just noticed the patch actually broke this module's functionality
https://www.drupal.org/project/uc_multiprice

What happens is the Countries and addresses format page will appear different.
http:/yourdmain.com/admin/store/settings/countries/formats

With uc_multiprice enabled without the patch, on the Countries and addresses format page, every country has its own "CURRENCY FORMAT".

After patch is applied, on the Countries and addresses format page, the "CURRENCY FORMAT" for individual country is gone and replaced by a global "CURRENCY FORMAT".

tr’s picture

Status: Needs work » Fixed

Not going to revert this, because it's the proper fix for the problem. Country format data and other form data (from the vertical tab e.g.) were being mixed at the same level of the render array, so it was impossible to tell which elements were country format and which were other random form data. When other random form data was encountered, a PHP notice was generated because there was no 'address_format' key for that other random data. The fix separated out the country format data into its own sub-array. Because the structure of the Ubercart country format form was changed by the patch, any contributed modules which alter that form will need to be changed too. I can't think of any other module than uc_multiprice which does this, so there is little impact on contrib from this change.

uc_multiprice will need a similar small patch, which I've posted in the uc_multiprice issue queue (but not tested, because I don't use uc_multiprice). See #2610998: Changes to work with latest -dev version of Ubercart. Please test that patch and comment in that issue to help get it into uc_multiprice.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.