-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.x]: Re-saving an address can mutate the first and last name on the address #14665
Comments
Yeah this is a known issue, but we don’t have a great solution for it. In Craft 4.6 we added the |
Right, but even with that setting on, there are scenarios with issues. Consider having NameTrait::prepareNamesForSave() doesn't check that config setting, it just checks the existence of the Now, in Commerce, when choosing an address to be also used as a billing address, the address element gets duplicated. Which means that, in this scenario, the billing address will end up with a different name, which also is likely to be wrong. The solution might be as simple as respecting the |
This is now resolved for Craft 4.9 and 5.1. Going forward, |
4.9 and 5.1 are out now with that change. |
What happened?
Description
If you have an address element with the middle name stuffed in either
firstName
orlastName
for any reason, saving the address element can yield unpredictable results.This is because of slightly circular logic in NameTrait. For example, if you have an Address element with
fullName
empty, butfirstName
andlastName
set, on save thefullName
field will become populated. Then, if you save the Address instead, thefullName
field gets parsed intofirstName
andlastName
fields, losing any middle names, if they were stored in those fields.For customers that strongly prefer avoiding using the
fullName
field, this can become problematic when dealing with Addresses in Commerce, especially considering that selecting billing address to be the same as shipping address will duplicate the element, in essence re-saving it and potentially mutating the data already.Steps to reproduce
In Craft shell
Expected behavior
One Two + Three Four = One Two Three Four
is printed twiceActual behavior
is printed instead, as the simple act of saving the Address element again changed the data.
Craft CMS version
4.7.2
Installed plugins and versions
The text was updated successfully, but these errors were encountered: