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

dev/core#2501 - api uf_group.create overwrites existing fields when updating if they aren't specified #19995

Merged
merged 1 commit into from
Apr 8, 2021

Conversation

demeritcowboy
Copy link
Contributor

Overview

https://lab.civicrm.org/dev/core/-/issues/2501

There are several fields that UFGroup::add() sets to FALSE if you don't specify, so for example updating just the title disables your profile because it sets is_active to 0. I can't think why this would be intentional and looking back through the history there doesn't seem to be a reason I can find.

To reproduce:

  1. Create a profile.
  2. Set some of the affected fields like the CMS user creation option and the Enable Mapping option.
  3. cv api uf_group.create id=15 title=testing, where id is the profile id. Or use api explorer.
  4. Back in the UI or in the database look at the fields. The profile is now disabled and those affected fields you set are cleared out.

Before

is_active, the setting for whether to offer cms user creation, mapping, etc, all get turned off.

After

As expected and the way other api calls work.

Technical Details

There are two additional parameters that have different names than their fields, so we need to keep that, but currently they overwrite with null if they're missing. But you might want to blank out a field, so we need to treat missing differently than empty.

Comments

Has test.

@civibot
Copy link

civibot bot commented Apr 7, 2021

(Standard links)

@civibot civibot bot added the master label Apr 7, 2021
@eileenmcnaughton
Copy link
Contributor

OK I took a look - I agree this is more correct and this is old code so not related to any recentish bug fixes. I think we can otherwise rely on db defaults

@eileenmcnaughton eileenmcnaughton merged commit a89a89a into civicrm:master Apr 8, 2021
@demeritcowboy
Copy link
Contributor Author

Thanks!

@demeritcowboy demeritcowboy deleted the ufgroup-active branch April 8, 2021 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants