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

Fix financial acl permissions to respect check_permissions #14118

Merged
merged 1 commit into from
May 11, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Fixes bug where check_permissions = 0 is ignored when doing contribution.get in conjunction with financial acls

Before

Flag ignored

After

Flag heeded

Technical Details

This enables a test whereby check_permissions is passed in & fixes by following the todo. It also removes
a couple of lines whereby the permissions are double-added in the contribution where clause - but
only if a field for which no special handling exists -we should rely on the main initialize function
(& over time make the inclusion more generic & consistent with our selectWhere approach) to avoid

  1. unnecessary joins
  2. ignoring the check_permission flag

Comments

@monishdeb @pradpnayak can one of you review?

This enables a test whereby check_permissions is passed in & fixes by following the todo. It also removes
a couple of lines whereby the permissions are double-added in the contribution where clause - but
only if a field for which no special handling exists -we should rely on the main initialize function
(& over time make the inclusion more generic & consistent with our selectWhere approach) to avoid
1) unnecessary joins
2) ignoring the check_permission flag
@civibot
Copy link

civibot bot commented Apr 24, 2019

(Standard links)

@civibot civibot bot added the master label Apr 24, 2019
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Apr 24, 2019
…essor id

This is preliminary cleanup towards exposing cancel_reason as a search field, as committed to in proposal to
add the field. This change

- adds unit tests for the trxn_id & processor_id fields
- makes the handling of them more generic
- adds contribution recur field data to the contribution query object so it can be accessed.

Some points about the last of these. Basically we have a situation where the query object needs metadata to
avoid field by field handling. We have done this is some wierd & wonderful ways with dependencies on 'import' &
'export' metadata info to the point where they were given to so many fields as to become meaningless.

I think this method is better - ie. just adding the additional metadata to the query class for all the entities it
deals with. A recently merged PR means 'where' data is still available using this method.

Also I have added uniquenames to the contribution recur fields. Uniquenames no longer really matter outside
- the query object
- profiles
- possibly import & export

We only really expose recurring contribution info through the query object of these so it should be safe. In a future happy
space apiv4 & namespacing will render uniquenames a distant memory.

I couldn't rip out the special handling entirely without dealing with the labels that go into the qill. I figure
we should merge this & then address that - but briefly the issue is that Matt has just changed all the labels
to not quite work in this context so we need to discuss / agree how to manage 'Recurring Contribution Trxn ID' vs
'Trxn ID'.

I also didn't want to rip out the special handling fully in advance of civicrm#14118
being merged as there could be a performance regression if we let more code hit that unnecessary join line
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Apr 25, 2019
…essor id

This is preliminary cleanup towards exposing cancel_reason as a search field, as committed to in proposal to
add the field. This change

- adds unit tests for the trxn_id & processor_id fields
- makes the handling of them more generic
- adds contribution recur field data to the contribution query object so it can be accessed.

Some points about the last of these. Basically we have a situation where the query object needs metadata to
avoid field by field handling. We have done this is some wierd & wonderful ways with dependencies on 'import' &
'export' metadata info to the point where they were given to so many fields as to become meaningless.

I think this method is better - ie. just adding the additional metadata to the query class for all the entities it
deals with. A recently merged PR means 'where' data is still available using this method.

Also I have added uniquenames to the contribution recur fields. Uniquenames no longer really matter outside
- the query object
- profiles
- possibly import & export

We only really expose recurring contribution info through the query object of these so it should be safe. In a future happy
space apiv4 & namespacing will render uniquenames a distant memory.

I couldn't rip out the special handling entirely without dealing with the labels that go into the qill. I figure
we should merge this & then address that - but briefly the issue is that Matt has just changed all the labels
to not quite work in this context so we need to discuss / agree how to manage 'Recurring Contribution Trxn ID' vs
'Trxn ID'.

I also didn't want to rip out the special handling fully in advance of civicrm#14118
being merged as there could be a performance regression if we let more code hit that unnecessary join line
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Apr 25, 2019
…essor id

This is preliminary cleanup towards exposing cancel_reason as a search field, as committed to in proposal to
add the field. This change

- adds unit tests for the trxn_id & processor_id fields
- makes the handling of them more generic
- adds contribution recur field data to the contribution query object so it can be accessed.

Some points about the last of these. Basically we have a situation where the query object needs metadata to
avoid field by field handling. We have done this is some wierd & wonderful ways with dependencies on 'import' &
'export' metadata info to the point where they were given to so many fields as to become meaningless.

I think this method is better - ie. just adding the additional metadata to the query class for all the entities it
deals with. A recently merged PR means 'where' data is still available using this method.

Also I have added uniquenames to the contribution recur fields. Uniquenames no longer really matter outside
- the query object
- profiles
- possibly import & export

We only really expose recurring contribution info through the query object of these so it should be safe. In a future happy
space apiv4 & namespacing will render uniquenames a distant memory.

I couldn't rip out the special handling entirely without dealing with the labels that go into the qill. I figure
we should merge this & then address that - but briefly the issue is that Matt has just changed all the labels
to not quite work in this context so we need to discuss / agree how to manage 'Recurring Contribution Trxn ID' vs
'Trxn ID'.

I also didn't want to rip out the special handling fully in advance of civicrm#14118
being merged as there could be a performance regression if we let more code hit that unnecessary join line
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Apr 26, 2019
…essor id

This is preliminary cleanup towards exposing cancel_reason as a search field, as committed to in proposal to
add the field. This change

- adds unit tests for the trxn_id & processor_id fields
- makes the handling of them more generic
- adds contribution recur field data to the contribution query object so it can be accessed.

Some points about the last of these. Basically we have a situation where the query object needs metadata to
avoid field by field handling. We have done this is some wierd & wonderful ways with dependencies on 'import' &
'export' metadata info to the point where they were given to so many fields as to become meaningless.

I think this method is better - ie. just adding the additional metadata to the query class for all the entities it
deals with. A recently merged PR means 'where' data is still available using this method.

Also I have added uniquenames to the contribution recur fields. Uniquenames no longer really matter outside
- the query object
- profiles
- possibly import & export

We only really expose recurring contribution info through the query object of these so it should be safe. In a future happy
space apiv4 & namespacing will render uniquenames a distant memory.

I couldn't rip out the special handling entirely without dealing with the labels that go into the qill. I figure
we should merge this & then address that - but briefly the issue is that Matt has just changed all the labels
to not quite work in this context so we need to discuss / agree how to manage 'Recurring Contribution Trxn ID' vs
'Trxn ID'.

I also didn't want to rip out the special handling fully in advance of civicrm#14118
being merged as there could be a performance regression if we let more code hit that unnecessary join line
@eileenmcnaughton
Copy link
Contributor Author

@pradpnayak @monishdeb could one of you review this?

@pradpnayak
Copy link
Contributor

looks good to me. did a quick simple test from ui and api, it worked when ACL financial type is enabled or disabled.

@eileenmcnaughton
Copy link
Contributor Author

Thanks @pradpnayak

@eileenmcnaughton eileenmcnaughton merged commit f386922 into civicrm:master May 11, 2019
@eileenmcnaughton eileenmcnaughton deleted the no_fin_item branch May 11, 2019 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants