diff --git a/Civi/Payment/PropertyBag.php b/Civi/Payment/PropertyBag.php index 92e06da0e657..14b865da2c35 100644 --- a/Civi/Payment/PropertyBag.php +++ b/Civi/Payment/PropertyBag.php @@ -268,7 +268,12 @@ protected function handleLegacyPropNames($prop, $silent = FALSE) { if ($newName === NULL && substr($prop, -2) === '-' . \CRM_Core_BAO_LocationType::getBilling() && isset(static::$propMap[substr($prop, 0, -2)]) ) { - $newName = substr($prop, 0, -2); + $billingAddressProp = substr($prop, 0, -2); + $newName = static::$propMap[$billingAddressProp] ?? NULL; + if ($newName === TRUE) { + // Good, modern name. + return $billingAddressProp; + } } if ($newName === NULL) { diff --git a/tests/phpunit/Civi/Payment/PropertyBagTest.php b/tests/phpunit/Civi/Payment/PropertyBagTest.php index 38443283df26..82f0be2e0c22 100644 --- a/tests/phpunit/Civi/Payment/PropertyBagTest.php +++ b/tests/phpunit/Civi/Payment/PropertyBagTest.php @@ -409,9 +409,10 @@ public function testEmpty() { } /** - * * Data provider for testOtherParams + * $prop, $legacy_names, $valid_values, $invalid_values * + * return array */ public function otherParamsDataProvider() { $valid_bools = [['0' , FALSE], ['', FALSE], [0, FALSE], [FALSE, FALSE], [TRUE, TRUE], [1, TRUE], ['1', TRUE]]; @@ -420,13 +421,14 @@ public function otherParamsDataProvider() { $valid_ints = [[123, 123], ['123', 123]]; $invalid_ints = [-1, 0, NULL, '']; return [ - ['billingStreetAddress', [], $valid_strings_inc_null, []], + ['billingStreetAddress', ['billing_street_address', 'street_address'], $valid_strings_inc_null, []], ['billingSupplementalAddress1', [], $valid_strings_inc_null, []], ['billingSupplementalAddress2', [], $valid_strings_inc_null, []], ['billingSupplementalAddress3', [], $valid_strings_inc_null, []], - ['billingCity', [], $valid_strings_inc_null, []], - ['billingPostalCode', [], $valid_strings_inc_null, []], + ['billingCity', ['billing_city', 'city'], $valid_strings_inc_null, []], + ['billingPostalCode', ['billing_postal_code', 'postal_code'], $valid_strings_inc_null, []], ['billingCounty', [], $valid_strings_inc_null, []], + ['billingStateProvince', ['billing_state_province', 'state_province'], $valid_strings_inc_null, []], ['billingCountry', [], [['GB', 'GB'], ['NZ', 'NZ']], ['XX', '', NULL, 0]], ['contributionID', ['contribution_id'], $valid_ints, $invalid_ints], ['contributionRecurID', ['contribution_recur_id'], $valid_ints, $invalid_ints],