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

Refactor CRM_Contact_BAO_Relationship::add to autoload missing params from existing record #15103

Merged
merged 1 commit into from
Aug 23, 2019

Conversation

mattwire
Copy link
Contributor

Overview

This is a pre-requisite to #15030. The BAO add method needed updating so it loads missing parameters directly using standard methods rather than requiring that they are all passed in to the function.

Before

Have to pass a lot of parameters to the CRM_Relationship_BAO_Relationship::add() function. Existing parameters not found by the function.

After

Per other standard functions, add() uses standard methods to find an existing record and use the params directly. This only happens if an ID is passed into the function.

Technical Details

Use standard DAO find() method.

Comments

@civibot
Copy link

civibot bot commented Aug 22, 2019

(Standard links)

@demeritcowboy
Copy link
Contributor

Thanks @mattwire - have taken a quick look and looks good so far. Give me a bit and I'll do a bit more.

@eileenmcnaughton
Copy link
Contributor

@mattwire I'd rather only do the load if we are missing specific params we need for the next processing steps - this could be part of a big batch update.

@mattwire mattwire force-pushed the relationshipaddbao branch from 2113ce0 to 94f43dd Compare August 23, 2019 09:25
@mattwire mattwire force-pushed the relationshipaddbao branch from 2d614ea to 5028849 Compare August 23, 2019 09:30
@mattwire
Copy link
Contributor Author

@mattwire I'd rather only do the load if we are missing specific params we need for the next processing steps - this could be part of a big batch update.

@eileenmcnaughton Ok I've done that

@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

This seems ok to me - will see if @demeritcowboy has further comments

@demeritcowboy
Copy link
Contributor

  • General standards
    • [r-explain] PASS
    • [r-user] PASS
    • [r-doc] PASS
    • [r-run] PASS
      • Looks good.
      • It's pre-existing but the head of household thing doesn't work because 6 is the wrong id, at least on the test site here. I'm not sure that feature would work properly anyway as written in all cases.
      • I don't currently see a way to test in the UI the situation where you haven't passed in enough params, which is partly what this was about. See also r-maint below.
  • Developer standards
    • [r-tech] PASS
    • [r-code] PASS
    • [r-maint] PASS
      • I notice there are no existing tests on the add() function directly. The api relationship-create is well-tested, so indirectly add() is tested, just as we know the api does more manipulation after calling add(), so some of those tests might be really testing that later code not add(). But it seems tested enough that it shouldn't hold this up. I don't mind writing a test about the lack of params to demonstrate the before and after, but you don't have to wait for me.
    • [r-test] PASS

@demeritcowboy
Copy link
Contributor

See test at #15121

@mattwire
Copy link
Contributor Author

It's pre-existing but the head of household thing doesn't work because 6 is the wrong id, at least on the test site here. I'm not sure that feature would work properly anyway as written in all cases.

I didn't like that there was a hardcoded ID there - but resisted the urge to fix because I couldn't find a an existing example and.. more PRs.. but as it's actually broken on your site here's a PR: #15123

@colemanw colemanw merged commit dabcb27 into civicrm:master Aug 23, 2019
@demeritcowboy
Copy link
Contributor

Thanks @mattwire. While I've always been a huge fan of the number 6 it's time for it to go. It's the wrong id on dmaster too and any stock new install.

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