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] Move addSelectWhere-like function to be located on BAO_Contribution #13587

Merged
merged 1 commit into from
Feb 16, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Feb 13, 2019

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

@civibot
Copy link

civibot bot commented Feb 13, 2019

(Standard links)

@civibot civibot bot added the master label Feb 13, 2019
public function addSelectWhereClause() {
$whereClauses = parent::addSelectWhereClause();
$originalWhereClauses = $whereClauses;
if ($whereClauses !== $originalWhereClauses) {
Copy link
Member

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.

Copy link
Contributor Author

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 :-)

Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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).

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this time?

Copy link
Member

Choose a reason for hiding this comment

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

Now it makes sense :)

Copy link
Contributor Author

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!

…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.
@seamuslee001
Copy link
Contributor

Jenkins re test this please

@eileenmcnaughton
Copy link
Contributor Author

@colemanw - it's passing now - this is tested from the getAnnualQuery test

@colemanw
Copy link
Member

LGTM. As Eileen and I have discussed, this could still use some more refactoring but this PR is a good first step.

@colemanw colemanw merged commit abd92d5 into civicrm:master Feb 16, 2019
@colemanw colemanw deleted the acl_location branch February 16, 2019 19:14
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.

3 participants