-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
CustomGroup - Ensure 'name' is always unique #22675
Conversation
(Standard links)
|
I wonder if we need some messaging - on the one hand we are changing We could possibly add a pre-message if any will be altered? Which would probably be rare but might alert them to any odd potential |
3ce7b66
to
e18b780
Compare
@eileenmcnaughton I've added the pre-upgrade check. |
Tests are green and I really think this needs to be merged asap. As @eileenmcnaughton points out, the existence of non-unique names would be flaky in managed entities... but it just occurred to me that they would be even flakier in APIv4, which relies on name uniqueness for getting and setting all custom data! |
It runs ok just two suggestions:
|
Previously, unique 'name' was only enforced in tandem with 'extends' Now it is required to be unique unconditionally.
e18b780
to
79b6ac2
Compare
Thanks for testing this @demeritcowboy. I've updated the message text, but kept the markup as-is because it's consistent with just about all other markup for pre-upgrade messages. I agree that making these messages easier to read is something to work on, but I see it as a separate issue. |
Overview
Stricter enforcement of CustomGroup name uniqueness.
Before
Previously, unique 'name' was indexed in tandem with 'extends'.
After
Now it is ensured to be unique unconditionally.
Technical Details
Note that at the form layer, unconditionally unique names have always been enforced, so in practice, every custom group name should already be unique.
civicrm-core/CRM/Custom/Form/Group.php
Lines 95 to 102 in aca7613
However this was never enforced at the BAO or API layer, so this PR includes an upgrade script to uniquify duplicate names.
Comments
The upgrade sql is simplistic, it will update any pair of duplicates found, but doesn't cover the possibility of triplets or quadruplets. But I think that's extremely unlikely - due to the enforcement that was happening at the form layer there really shouldn't be any duplicates at all; so the upgrade sql is there as a safeguard rather than a necessity.