-
-
Notifications
You must be signed in to change notification settings - Fork 825
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] Move addSelectWhere-like function to be located on BAO_Contribution #13587
Conversation
(Standard links)
|
CRM/Contribute/BAO/Contribution.php
Outdated
public function addSelectWhereClause() { | ||
$whereClauses = parent::addSelectWhereClause(); | ||
$originalWhereClauses = $whereClauses; | ||
if ($whereClauses !== $originalWhereClauses) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton I'm confused about what this code is doing. It assigns a variable to another variable, and then immediately checks if they are equal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colemanw did you read the comment below? Basically we have an issue where we have financial acls in the hook AND the extension & we don't want both to apply. Originally the only places that called the hook DIDN'T apply the financial acls & vice versa.
Long term we want to only use the extension or only call the lines below this return. Joe doesn't yet know that he agrees with me on which one :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did read the comment but the code still doesn't make logical sense to me. It's basically saying:
function checkIfFooEqualsFoo() {
$foo = rand();
$bar = $foo;
if ($bar !== $foo) {
// this will never happen. Why are we checking for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colemanw it WOULD happen if the parent 's call to the financialACLHook hit the financialaclreport extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I still don't see how. Even if the rand()
function in my example were to call a hook, it's still assigning the output of that hook to two variables which will always be exactly the same no matter what, and then comparing them to see if they are exactly the same (they are).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah - I mis-ordered when I brought across - I see now - fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok now the first line of the function seems to be trying to access an undefined variable $whereClauses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it makes sense :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for persevering with me!
2137bb2
to
2ff41e6
Compare
…sing correct name. Since the contribution api uses the BAO_Query object I think it will not call this, nor reports AFAIK However, this should cause the v4 api to apply these.
2ff41e6
to
6107673
Compare
Jenkins re test this please |
@colemanw - it's passing now - this is tested from the getAnnualQuery test |
LGTM. As Eileen and I have discussed, this could still use some more refactoring but this PR is a good first step. |
Overview
This is a code relocation / standardisation to use the std location for applying acls to contributions
Before
Function in a random place
After
Function in the std place
Technical Details
Having a function to add ACLs in addSelectWhere on the BAO is the standard. There is a question as to whether this goes on the contribution BAO or on the financialType BAO & we put something in the parent to call in the financialType acl whenever it's an FK on the entity. However, that could be resolved in a follow up
Comments
Note this is covered by the recently added annualQuery test