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 malformed query when user with no access to any financial acls accesses civimember search #23228

Merged
merged 1 commit into from
Apr 18, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

  1. enable financial acls
  2. give civimember access to webuser
  3. log in as advisor/advisor & access membership search

Before

image

After

image

Technical Details

The contact cannot view any memberships but returning 0 winds up dropped - '= 0' works...

Comments

@civibot
Copy link

civibot bot commented Apr 15, 2022

(Standard links)

@colemanw
Copy link
Member

@eileenmcnaughton so if I'm understanding this correctly the malformed sql is AND AND - it should be AND 0 AND but there's probably some php !empty() check which short-circuits?
But I'm confused about how AND =0 AND would actually be ok sql.
A lot of other funcitons like this return the string "(0)" instead of just "0".

@eileenmcnaughton
Copy link
Contributor Author

@colemanw it winds up as 'membership_type_id = 0' - I think maybe it got filtered out of something - I'm not sure exactly now cos my brain didn't hold it - but on r-run it was pretty clear that it failed before & worked after!

@colemanw
Copy link
Member

@eileenmcnaughton ok but I still can't make sense of line 228: return 1;. Wouldn't that also create bad sql?

@eileenmcnaughton
Copy link
Contributor Author

@colemanw hmm - that return 1 was added here #22864 - I'm just trying to test but hit ... yet another bug in the acls

@eileenmcnaughton
Copy link
Contributor Author

Ok - here was the bug I just hit... #23235

@eileenmcnaughton
Copy link
Contributor Author

eileenmcnaughton commented Apr 17, 2022

@colemanw I've fixed it to return '=0' when civiMember is disabled too - I couldn't actually hit it this time - but it should be the same for when CiviMember is disabled as when there are no available membership types - MembershipType api still works 'correctly' with civimember disabled - although I think it's kinda tough for code writers that it throws an exception (even with checkPermissions=FALSE I think) in v4 api

@colemanw
Copy link
Member

Ok. I see that this function is supposed to return the latter 2/3 of a WHERE clause (the operator and the value) and now it consistently does so.

@colemanw colemanw merged commit 66a8a4c into civicrm:5.49 Apr 18, 2022
@colemanw colemanw deleted the 549_m branch April 18, 2022 02:31
@colemanw
Copy link
Member

@eileenmcnaughton the thinking behind it is that we are moving components to be more extension-like (and even moving some components to be extensions) so APIv4 helps with that transition. In v3 disabled extensions would throw an exception if you tried their api, but disabled components would not. In v4 it's consistent: calling the Volunteer api with CiviVolunteer disabled throws the same exception as calling the Member api with CiviMember disabled.

@eileenmcnaughton
Copy link
Contributor Author

hmm ok - ....

@eileenmcnaughton eileenmcnaughton mentioned this pull request Apr 19, 2022
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