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#2153 #REF Remove outdated updateCustomValues function #18959

Merged
merged 1 commit into from
Nov 22, 2020

Conversation

seamuslee001
Copy link
Contributor

Overview

As per #18912 (comment) This removes the outdated updateCustomValues function and replaces its current usage with updateValue

Before

Outdated function called from a couple of places

After

Outdated function removed

ping @yashodha @demeritcowboy @eileenmcnaughton @colemanw

@civibot
Copy link

civibot bot commented Nov 12, 2020

(Standard links)

@civibot civibot bot added the master label Nov 12, 2020
@@ -397,7 +397,7 @@ public function postProcess() {
$oldWeight = NULL;
if ($this->_id) {
$customOption->id = $this->_id;
CRM_Core_BAO_CustomOption::updateCustomValues($params);
CRM_Core_BAO_CustomOption::updateValue($customOption->id, $customOption->value);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this is just shifting the updateValue call from L487 to here to match how the code was originally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking that was buggy before and having it down below is maybe better. For example suppose line 472 changes $customOption->value. Then if the update is here you've already updated existing ones to something that is different from what gets saved in civicrm_option_value.

Having it at the bottom as it is right now calls the function even on new fields, but could wrap in if ($customOption->id)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok have moved it back now @demeritcowboy

@demeritcowboy
Copy link
Contributor

Did you guys discuss the cleanMoney part - updateValue doesn't clean the money - not sure if that really matters anywhere.

@seamuslee001
Copy link
Contributor Author

@demeritcowboy we felt that cleanMoney is only really needed on the form layer

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Nov 16, 2020

  1. Calling updateValue when customOption->id is null is a little dangerous since it then thinks you're updating Phone communication preference (the DAO->find() just returns the first option value in the whole list). It's unlikely you have a custom field somewhere using that option group for its choices, but it would go and try to update value 1. The updateValue function should either fail hard if you give it null id, or just return.

  2. It doesn't work for type money (clean or dirty). Maybe it never did for either function? It doesn't work if I do it from system settings - option groups either. Not sure why yet.

@demeritcowboy
Copy link
Contributor

For the monies, I see it's because the custom db column is created as decimal(20,2), so if you have an option value of 10, with no decimals, the option value stores it as 10, but the custom table stores it as 10.00, so it doesn't match when it goes to update. So that's a separate issue - I'll make a ticket.

@@ -198,7 +198,7 @@ public static function del($optionId) {
'value' => $value,
];
// delete this value from the tables
self::updateCustomValues($params);
self::updateValue($dao->id, $value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be self::updateValue($optionId, $value);

@eileenmcnaughton
Copy link
Contributor

@demeritcowboy is this currently mergeable?

@demeritcowboy
Copy link
Contributor

I don't think so. It doesn't pass the correct id for deletions, and calling it for new option values is dangerous unless updateValue is changed to ignore null ids. But can ignore the money stuff for now.

@eileenmcnaughton
Copy link
Contributor

OK - in your court then @seamuslee001

Move function call back to where it was under cividesk

Fix delete and ensure updateValue is only called on update
@seamuslee001
Copy link
Contributor Author

@demeritcowboy should be sorted now can you check

@demeritcowboy
Copy link
Contributor

Looks good to me.

@eileenmcnaughton eileenmcnaughton merged commit a990044 into civicrm:master Nov 22, 2020
@eileenmcnaughton eileenmcnaughton deleted the dev_core_2153_2 branch November 22, 2020 00:53
@yashodha
Copy link
Contributor

@seamuslee001 looks good, thanks!

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.

4 participants