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#155 Allow saving of new option value with value = 0. #12229

Merged
merged 2 commits into from
May 30, 2018

Conversation

mattwire
Copy link
Contributor

Overview

Allow saving of new option value with value = 0.

Before

Could not save new option value with value=0.
After

Can save option value with value=0, no warning that datatype does not match.

Technical Details

Code was using empty() and !$variable which both treat 0 as FALSE. These are changed to !isset() and $variable === FALSE respectively.

Comments

Long-standing bug that's been around since 4.6!

@eileenmcnaughton
Copy link
Contributor

[GitScan\Exception\ProcessErrorException]
Process failed:
[[ COMMAND: git apply --check --ignore-whitespace ]]
[[ CWD: /home/jenkins/buildkit/build/core-12229-23ix1/sites/all/modules/civicrm ]]
[[ EXIT CODE: 1 ]]
[[ STDOUT ]]
[[ STDERR ]]
error: patch failed: CRM/Admin/Form/Options.php:450
error: CRM/Admin/Form/Options.php: patch does not apply

@eileenmcnaughton
Copy link
Contributor

@mattwire I have been discussing with @colemanw switching over the OptionValue form to use the api so this might be a short-lived change. There are some metadata things to work through to make that step but basically that is where we want to go (& to eventually allow custom data on that form although we might need to think about whether that custom data can be extended by option group)

@eileenmcnaughton
Copy link
Contributor

Merging this as it does address the issue as described and the clean ups all appear correct. Per comments above - we do hope to deprecate the function

@eileenmcnaughton eileenmcnaughton merged commit a1add9e into civicrm:master May 30, 2018
@eileenmcnaughton
Copy link
Contributor

@mattwire is there a gitlab issue to close?

@mattwire mattwire changed the title Allow saving of new option value with value = 0. dev/core#155 Allow saving of new option value with value = 0. May 31, 2018
@JoeMurray
Copy link
Contributor

I realize this has been merged, and I like the idea in general. However, I'm wondering if any thought or testing went into whether having a zero value option will cause issues in code that uses option values.

@mattwire
Copy link
Contributor Author

mattwire commented Jun 1, 2018

@JoeMurray This only affects creating new ones, it's always been possible to update to value=0 via UI after creation. The value 0 is being used quite extensively on a few sites which have wellbeing style questionnaires , eg How are you feeling 0,1,2,3,4

@JoeMurray
Copy link
Contributor

I understood this was only for new. I'm pleased to hear that you have experience that using 0 as a value has not led to issues being surfaced elsewhere in code. I'm satisfied.

@mattwire mattwire deleted the optionvalue_fixes branch September 25, 2018 11:01
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