Skip to content

Map every Address field country to a country code - #3800

Merged
Crabcyborg merged 1 commit into
masterfrom
fix/missing-country-codes
Dec 2, 2026
Merged

Crabcyborg merged 1 commit into
masterfrom
fix/missing-country-codes

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

14 countries in the Address field dropdown (FrmFieldsHelper::get_countries()) had no entry in the country code map, so get_country_code() returned an empty string for them. A Stripe customer created from one of these addresses got no country. This came up in the review of https://github.com/Strategy11/formidable-stripe/pull/536.

The dropdown spellings are added as aliases of the codes the map already had:

Dropdown name Code Existing map name
Bonaire, Sint Eustatius and Saba BQ Bonaire, Saint Eustatius and Saba
Côte d'Ivoire, Côte d'Ivoire CI Ivory Coast
Cocos (Keeling) Islands CC Cocos Islands
Congo CG Republic of the Congo
Falkland Islands (Malvinas) FK Falkland Islands
Holy See, Vatican City VA Vatican
Palestine PS Palestinian Territory
Saint Helena, Ascension and Tristan da Cunha SH Saint Helena
Saint Martin (French part) MF Saint Martin
Sint Maarten (Dutch part) SX Sint Maarten
Timor-Leste TL East Timor
Virgin Islands, British VG British Virgin Islands
Virgin Islands, U.S. VI U.S. Virgin Islands

The dropdown stores Côte d'Ivoire as Côte d'Ivoire, which the templates pass to get_country_code(). A submitted entry holds the decoded Côte d'Ivoire, so both spellings are mapped.

Lite and Pro each keep their own copy of the map (FrmAddressesController and FrmProAddressesController), and both were identical before this change. Both get the same entries: the Pro change is in https://github.com/Strategy11/formidable-pro/pull/7067.

Not covered: translated country names. The map is keyed by the English names, so a translated dropdown still gets no code. That was already true before this change.

Testing

  • New test test_get_country_code_covers_every_country_option loops over every dropdown country and fails if any gets an empty code. It failed with 14 countries before the change and passes after.
  • New test test_get_country_code_maps_decoded_country_name checks the decoded Côte d'Ivoire name.
  • test_FrmFieldAddress: OK, 54 tests, 139 assertions. With the map change reverted, both new tests fail.
  • phpcs, php-cs-fixer, rector and phpstan are clean on the changed files.

14 countries in the Address field dropdown had no entry in the
country code map, so get_country_code() returned an empty string for
them. Add the dropdown spellings as aliases of the existing entries,
plus the decoded Cote d'Ivoire name that a submitted entry holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d4bf9a3 and 6458a24.

Files selected for processing: 2

  • classes/controllers/FrmAddressesController.php
  • tests/phpunit/fields/test_FrmFieldAddress.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@deepsource-io

deepsource-io Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in d4bf9a3...6458a24 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Dec 2, 2026 1:51p.m. Review ↗
JavaScript Dec 2, 2026 1:51p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@Crabcyborg Crabcyborg added this to the 7.2 milestone Dec 2, 2026
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Dec 2, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. Nothing blocking. The fix does what the description says, and I reproduced the bug before and after.

Verified

  • Before (master's FrmAddressesController.php, PR's tests kept): both new tests fail. test_get_country_code_covers_every_country_option lists exactly the 14 dropdown countries from the description with no code: Bonaire, Sint Eustatius and Saba; C&ocirc;te d'Ivoire; Cocos (Keeling) Islands; Congo; Falkland Islands (Malvinas); Holy See; Palestine; Saint Helena, Ascension and Tristan da Cunha; Saint Martin (French part); Sint Maarten (Dutch part); Timor-Leste; Vatican City; Virgin Islands, British; Virgin Islands, U.S.
  • After (PR head): all 14 map, and test_get_country_code_maps_decoded_country_name passes for Côte d'Ivoire.
  • Codes checked: BQ, CI, CC, CG, FK, VA, PS, SH, MF, SX, TL, VG, VI are the correct ISO 3166-1 alpha-2 codes for those names. Each alias points at the same code as the name already in the map (for example Congo → CG, same as Republic of the Congo; Congo DR is untouched).
  • No duplicate keys in the 265-entry array, so no alias silently overwrites another.
  • get_country_codes() has no caller in the Lite, Pro, Stripe or Stripe Connect plugin code in the local harness, so the extra aliases cannot change a reverse lookup there.

Tests run: phpunit -c phpunit.xml tests/phpunit/fields/test_FrmFieldAddress.php at 6458a2461 (PR copied into the local WordPress harness, PHP 8.4) → OK, 54 tests / 139 assertions, matching the PR description. CI's PHPUnit job is skipped on this PR, so this is the only run.

Not exercised: a real Address field submission and Stripe customer creation (the test calls get_country_code() directly), and the Pro copy of the map, which is in #7067.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Dec 2, 2026
@Crabcyborg

Copy link
Copy Markdown
Contributor Author

Pro no longer duplicates these entries. https://github.com/Strategy11/formidable-pro/pull/7067 now calls Lite's get_country_code() on Lite 6.34 and later, and keeps its own map only for older Lite.

@Crabcyborg
Crabcyborg merged commit 4bd8139 into master Dec 2, 2026
63 checks passed
@Crabcyborg
Crabcyborg deleted the fix/missing-country-codes branch December 2, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant