Skip to content

Commit c5b6158

Browse files
committed
Tweak - Narrow the rate-row growth claim to the states that actually duplicated.
The changelog entry named three triggers — a period, a space, and a non-Latin character. Measured against core, only one of the three is right. WC_Tax::prepare_tax_rate() stores tax_rate_state as strtoupper( sanitize_key() ), and WC_Tax::get_matched_tax_rates() matches it with `tax_rate_state IN ( %s, '' )`. So a row is unfindable — and duplicated on every calculation — only when the stored value is non-empty *and* differs from what the lookup asked for. A space never diverged: the old str_replace( ' ', '' ) lookup happened to agree with sanitize_key() there, and only there. A state that collapses to '' outright never diverged either, because the blank satisfies the second arm of the IN clause whatever was asked for. What actually duplicated is a state that collapses *partially*, to a shorter non-empty code: 'N.Y.' -> 'NY', 'ÎF' -> 'F'. Rewords the entry to key on the mechanism rather than on scripts, and applies the same correction to readme.txt, which carries the published verbatim copy. The state_compact() docblock carried the same overbroad claim and gains the boundary.
1 parent 77107d4 commit c5b6158

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Fix - Prevent tax calculation from failing when the store address postcode holds more than one comma-separated value.
1010
* Fix - Accept lower-case country and state codes from the woocommerce_taxjar_nexus_address filter.
1111
* Fix - Fall back to the store address when a custom nexus address is incomplete instead of abandoning the calculation.
12-
* Fix - Prevent unbounded growth of WooCommerce tax rate rows when the customer state contains a period, a space, or a non-Latin character.
12+
* Fix - Prevent unbounded growth of WooCommerce tax rate rows when the customer state contains a character WooCommerce strips before storing it, such as a period or an accented letter.
1313
* Fix - Restore tax rates on the price display, shipping tax and coupon paths for addresses whose state was stored in a normalized form.
1414
* Tweak - Centralize TaxJar address handling in an internal value object. No change to tax calculation.
1515
* Tweak - Store tax rate rows against the postcode the rate was quoted for when the address postcode holds more than one comma-separated value.

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ This plugin relies on the following external services:
7979
* Fix - Prevent tax calculation from failing when the store address postcode holds more than one comma-separated value.
8080
* Fix - Accept lower-case country and state codes from the woocommerce_taxjar_nexus_address filter.
8181
* Fix - Fall back to the store address when a custom nexus address is incomplete instead of abandoning the calculation.
82-
* Fix - Prevent unbounded growth of WooCommerce tax rate rows when the customer state contains a period, a space, or a non-Latin character.
82+
* Fix - Prevent unbounded growth of WooCommerce tax rate rows when the customer state contains a character WooCommerce strips before storing it, such as a period or an accented letter.
8383
* Fix - Restore tax rates on the price display, shipping tax and coupon paths for addresses whose state was stored in a normalized form.
8484
* Tweak - Centralize TaxJar address handling in an internal value object. No change to tax calculation.
8585
* Tweak - Store tax rate rows against the postcode the rate was quoted for when the address postcode holds more than one comma-separated value.

src/Tax/Address.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@ public function state(): string {
367367
* to do) covers `'N Y'` and nothing else: `'N.Y.'`, and any state carrying
368368
* non-ASCII, still diverge.
369369
*
370+
* One boundary to that story: a state `sanitize_key()` empties *outright* (`'ЛЕН'`,
371+
* `'东京'`) was never the duplicating shape, because the blank it stores satisfies
372+
* the `''` arm of that `IN` clause whatever the lookup asked for. The rows that
373+
* could not be found again are the ones that collapse *partially*, to a shorter
374+
* non-empty code — `'ÎF'` stored as `'F'`.
375+
*
370376
* Because core applies the same function on the way in, mirroring it here cannot
371377
* lose information the stored value still has.
372378
*

0 commit comments

Comments
 (0)