cck_address_get_states uses state abbreviation as array key - states with same abbreviation will not show
| Project: | Address field for CCK |
| Version: | 5.x-2.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
This portion of code from the cck_address_get_states shows how the state abbreviation is used as the key for the array of states returned:
$results = db_query($sql);
while ($result = db_fetch_object($results)) {
$state_options[$result->state_abbrv] = $result->state_name;
}
return $state_options;This is generally fine, unless you have multiple countries (and ask this function to show all states by not passing a country to it) and states in one country share the same abbreviation as states in another country. For example Australia has WA for Western Australia, and USA has WA for Washington. Regardless of which countries are currently supported or released, this problem will come up in the future.
I think this array should be indexed by the state_id field used in the cck_address_states database table. I am not sure of all the places this function is called from though or what the results of such a change would be. Just wanted to get this submitted.
