Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • C CiviCRM Core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,372
    • Issues 1,372
    • List
    • Boards
    • Service Desk
    • Milestones
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • CiviCRM Core
  • Issues
  • #725

Closed
Open
Created Feb 14, 2019 by jackrabbithanna@jackrabbithannaDeveloper

Address API incorrectly sets state_province_id if multiple countries have same state name / abbreviation

Replicable on dmaster.demo

The Address API is not taking into account the country_id when figuring the state_province_id when given the state name or state abbreviation, even if country_id is provided...

Example:

    $result = civicrm_api3('Address', 'create', [
      'contact_id' => 206,
      'location_type_id' => "Main",
      'city' => "Baltimore",
      'state_province_id' => "Maryland",
      'country_id' => 1228,
    ]);

Output:

{
    "is_error": 0,
    "version": 3,
    "count": 1,
    "id": 193,
    "values": {
        "193": {
            "id": "193",
            "contact_id": "206",
            "location_type_id": "3",
            "is_primary": "1",
            "is_billing": "0",
            "city": "Baltimore",
            "state_province_id": "3497",
            "country_id": "1228",
            "manual_geo_code": "0"
        }
    }
}

Notice the state_province_id is 3497, which is Maryland, Liberia. It should be 1019.

This happens regardless of which countries are enabled in the Localization settings. It also does not respect the "default country" setting, if the country_id is not provided.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking