Problem/Motivation

  • Enable either the location_node module or the location_cck module
  • Set up a country field and province field in a content type
  • Create a new node and select a country (e.g. UK) and a province (e.g. Cheshire) and save the node
  • Edit the node, change the country (e.g. Canada), select a new province (e.g. Prince Edward Island)
  • Save the node - you should get an error message: "An illegal choice has been detected. Please contact the site administrator.".

Proposed resolution

Line 283 in location.module in function _location_expand_location() checks if ['value']['country'] is set on the current element, and if not, uses the default country to determine the list of provinces. This should most probably be checking ['#value']['country'] on that element, as ['value']['country'] is not present on this element even where a country has been selected on the form. Patch attached.

I am guessing that this bug may have been introduced at some point since 6.x-3.2 as that version appears to check for ['#value']['country'].

Remaining tasks

Needs testing.

CommentFileSizeAuthor
#9 location-2139429-9.patch909 bytesroball
location.module.patch575 bytesneilt17
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

neilt17’s picture

Title: Changing country and then selecting a province returns error "An illegal choice has been detected. Please contact the site administrator" » Changing country and then selecting a province returns error "An illegal choice has been detected. Please contact the site administrator."
Summit’s picture

Status: Active » Reviewed & tested by the community

Hi,

Great catch, I had to change this also to get it to work!
Thanks!

Greetings, Martijn

Status: Reviewed & tested by the community » Needs work

The last submitted patch, location.module.patch, failed testing.

gpvdo’s picture

Please see 'location_element' in Drupal form with Country/Province(select) AJAX update

Changing ['value']['country'] to ['#value']['country'] is needed but not sufficient else one could run into validation errors.

roball’s picture

Priority: Normal » Major

Getting the same error on all D6 sites since updating Location from 6.x-3.2 to 6.x-3.3.

roball’s picture

Version: 6.x-3.3 » 6.x-3.x-dev

Trying to make the testbot happy

Status: Needs work » Needs review

roball queued location.module.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, location.module.patch, failed testing.

roball’s picture

Status: Needs work » Needs review
FileSize
909 bytes

Re-rolled patch in correct Drupal format.

roball’s picture

Status: Needs review » Reviewed & tested by the community

The bug has been introduced with commit 20e15f on 2013-09-10, released in version 6.x-3.3-rc1, on trying to fix #2084133: Illegal string offset 'country' in location/location.module on line 282..

podarok, could you please commit the patch from #9 above which fixes the bug? I have tested it and can confirm that it indeed fixes the issue. Thanks.

joelpittet’s picture

RTBC++

podarok’s picture

Status: Reviewed & tested by the community » Fixed

thanks, fixed.

  • podarok committed 8f91fe9 on 6.x-3.x authored by roball
    Issue #2139429 by roball, neilt17, joelpittet: Changing country and then...
roball’s picture

Thanks podarok for committing and releasing Location 6.x-3.4!

podarok’s picture

You are welcome
I have no more sites with 6.x version, so it is possible to get it supported due to community activity only

Status: Fixed » Closed (fixed)

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