Skip to content
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

Bugfix/15678 user addresses and fields #15685

Merged
merged 8 commits into from
Sep 6, 2024

Conversation

i-just
Copy link
Contributor

@i-just i-just commented Sep 6, 2024

Description

First issue:
User‘s nested addresses owned by a custom field appear in the main Addresses view when editing that user.

Fix:
User->getAddresses() should return user's "native" addresses - the ones linked via the addresses attribute and not via a custom Addresses field.

The above also fixes the issue where deleting the custom Addresses field caused an error about a missing field when visiting the user's Addresses screen.

Second issue:
After deleting an Addresses field, the fieldId is not cleaned up, nor are the nested elements deleted. Garbage collection also doesn't clear those out.

Fix:
This happens because there's no foreign key constraint on the addresses.fieldId field.
I added a migration that will delete all the addresses that are linked to a field that's been hard deleted and then add a foreign key constraint to the fieldId column. I also adjusted the Gc service to run partial elements deletion on Addresses.

Related issues

#15678

@i-just i-just marked this pull request as draft September 6, 2024 11:21
@i-just
Copy link
Contributor Author

i-just commented Sep 6, 2024

I moved it back to draft as there's a way to approach the second problem that is more consistent with what we already have in place.

@i-just i-just marked this pull request as ready for review September 6, 2024 12:17
@brandonkelly brandonkelly merged commit b7bd7d6 into 5.x Sep 6, 2024
@brandonkelly brandonkelly deleted the bugfix/15678-user-addresses-and-fields branch September 6, 2024 16:36
@brandonkelly
Copy link
Member

Went with a garbage collection-only approach so we can avoid adding a new migration, and because relying on cascading deletes was only a partial solution anyway (requiring deletePartialElements() to finish the job).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants