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

[REF] clarify variable (very minor change with good test cover) #14724

Merged
merged 1 commit into from
Jul 4, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Very minor code cleanup

Before

Less readable

After

More readable

Technical Details

I'm trying to reduce the cognitive load in #14694 - this has thorough test coverage

Comments

@civibot
Copy link

civibot bot commented Jul 3, 2019

(Standard links)

The variable is clearer being defined directly as 'add' or 'modify' in the main function to reduce wrangling
@eileenmcnaughton
Copy link
Contributor Author

test this please

}

// complete transaction
$transaction->commit();

CRM_Utils_Hook::post($op, 'CustomField', $customField->id, $customField);
CRM_Utils_Hook::post(($op === 'add' ? 'create' : 'edit'), 'CustomField', $customField->id, $customField);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use same concept here?
empty($params['id']) ? 'create' : 'edit';

Since hook_pre() allows once to change the $params and its possible that one can set $params['id'](very rare case though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pradpnayak I thought about your comment here but in other BAO the op is determined before calling the 'pre' hook & retained for the post hook so that would be inconsistent with other BAO. I am going to add some code comments but to a subsequent PR as they need rebasing after the merges that have been done so far

@pradpnayak
Copy link
Contributor

Did a QA on current state of code.

Testcase: Added/Updated custom field via UI and api.
Result: Custom field was added/updated.

Safe to merge(If the change requested doesn't make sense)

@eileenmcnaughton eileenmcnaughton merged commit 5e090ed into civicrm:master Jul 4, 2019
@eileenmcnaughton eileenmcnaughton deleted the cust_field3 branch July 4, 2019 21:43
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