CiviContribute - Fix SQL error when interpreting ACL #23235
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Fixes a regression sql error in the annual query (e.g on contribution tab) for an acld user without permission to view deleted contacts in 5.48+
Before
Fatal ...
SELECT COUNT(*) AS count, SUM(total_amount) AS amount, AVG(total_amount) AS average, currency
FROM civicrm_contribution b
WHERE b.contact_id IN (SELECT contact_id FROM civicrm_acl_contact_cache WHERE user_id = 202)
AND b.contact_idIN(SELECT
id
FROMcivicrm_contact
WHERE is_deleted != 1)AND b.financial_type_id IN (1)
AND b.contact_id IN (71)
AND b.is_test = 0
AND b.receive_date >= 20220101
AND b.receive_date < 20230101
GROUP BY currency, contribution_status_id
HAVING contribution_status_id = 1
After
works
Technical Details
This patch
56f5e9d#diff-4c9d0b1abe07057a4eea2b47bc627eecb95face8ed8d86c1c005312a52cca811R4377
added the acl for deleted contacts - but it is being joined with no space
Comments
We should backport but the fact it is tied to the view deleted permission is probably why no-one noticed as yet...