CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Contribution and Membership Details report fails for ACL restricted users
Pages: [1]

Author Topic: Contribution and Membership Details report fails for ACL restricted users  (Read 1514 times)

Andrew Cormick-Dockery

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7
  • MySQL version: 5.5.43-MariaDB
  • PHP version: 5.4.39
Contribution and Membership Details report fails for ACL restricted users
January 15, 2014, 08:11:30 pm
When logged in as an ACL restricted user, the Contribution and Membership Details report fails with the error message "Sorry but we are not able to provide this at the moment.  DB Error: syntax error".  See civicrm/report/member/contributionDetail?reset=1

We performed this on version 4.4.3 of CiviCRM

The error report shows a malformed SQL query:

Code: [Select]
INSERT INTO civireport_membership_contribution_detail (contribution_id, contact_id, membership_id)
          SELECT contribution.id, contact.id, m.id
          FROM civicrm_contribution contribution
          INNER JOIN civicrm_contact contact  INNER JOIN civicrm_acl_contact_cache aclContactCache ON contact_civireport.id = aclContactCache.contact_id
                ON contact.id = contribution.contact_id AND contribution.is_test = 0
           LEFT JOIN civicrm_membership_payment mp
                ON contribution.id = mp.contribution_id
           LEFT JOIN civicrm_membership m
                ON mp.membership_id = m.id AND m.is_test = 0  [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaD
B server version for the right syntax to use near 'contact.id = contribution.contact_id AND contribution.is_test = 0
           LEF' at line 5]

Note how the INNER JOIN for the ACL related table seems to be placed right into the middle of the contact INNER JOIN clause.

The stack trace confirms that the calling function originates from CRM/Report/Form/Member/ContributionDetail.php(641)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Contribution and Membership Details report fails for ACL restricted users
January 16, 2014, 08:47:42 am

hey andrew:

can u take a look at the code and see where that bad sql interpolation is happening. if you can investigate and propose a patch for it, that would be great

thanx

lobo


lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Andrew Cormick-Dockery

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7
  • MySQL version: 5.5.43-MariaDB
  • PHP version: 5.4.39
Re: Contribution and Membership Details report fails for ACL restricted users
January 16, 2014, 03:45:07 pm
Huh, that was a lot simpler than I thought it was.  Patch below (git diff)

Code: [Select]
diff --git a/CRM/Report/Form/Member/ContributionDetail.php b/CRM/Report/Form/Member/ContributionDetail.php
index 442c6f8..7972900 100644
--- a/CRM/Report/Form/Member/ContributionDetail.php
+++ b/CRM/Report/Form/Member/ContributionDetail.php
@@ -631,8 +631,9 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
           INSERT INTO civireport_membership_contribution_detail (contribution_id, contact_id, membership_id)
           SELECT contribution.id, contact.id, m.id
           FROM civicrm_contribution contribution
-          INNER JOIN civicrm_contact contact {$this->_aclFrom}
+          INNER JOIN civicrm_contact contact
                 ON contact.id = contribution.contact_id AND contribution.is_test = 0
+          {$this->_aclFrom}
            LEFT JOIN civicrm_membership_payment mp
                 ON contribution.id = mp.contribution_id
            LEFT JOIN civicrm_membership m
« Last Edit: January 16, 2014, 03:48:18 pm by Andrew Dockery »

seamuslee

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
  • CiviCRM version: 4.4.6
  • CMS version: Drupal 7.x
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Contribution and Membership Details report fails for ACL restricted users
January 16, 2014, 04:05:58 pm
Hi Folks

I added this in the issue tracker here http://issues.civicrm.org/jira/browse/CRM-14085 so we can make sure it gets contributed to core.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Contribution and Membership Details report fails for ACL restricted users

This forum was archived on 2017-11-26.