Repository navigation
Map every Address field country to a country code - #3800
Conversation
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>
|
Warning Review limit reachedYou'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. View limit details
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. |
|
|
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.
There was a problem hiding this comment.
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_optionlists exactly the 14 dropdown countries from the description with no code: Bonaire, Sint Eustatius and Saba;Cô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_namepasses forCô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 asRepublic 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.
|
Pro no longer duplicates these entries. https://github.com/Strategy11/formidable-pro/pull/7067 now calls Lite's |
14 countries in the Address field dropdown (
FrmFieldsHelper::get_countries()) had no entry in the country code map, soget_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:
The dropdown stores Côte d'Ivoire as
Côte d'Ivoire, which the templates pass toget_country_code(). A submitted entry holds the decodedCôte d'Ivoire, so both spellings are mapped.Lite and Pro each keep their own copy of the map (
FrmAddressesControllerandFrmProAddressesController), 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
test_get_country_code_covers_every_country_optionloops over every dropdown country and fails if any gets an empty code. It failed with 14 countries before the change and passes after.test_get_country_code_maps_decoded_country_namechecks the decoded Côte d'Ivoire name.test_FrmFieldAddress: OK, 54 tests, 139 assertions. With the map change reverted, both new tests fail.