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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • DB error in Contribution details report
Pages: [1]

Author Topic: DB error in Contribution details report  (Read 343 times)

shadowcrawler

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal
  • MySQL version: 5.1
  • PHP version: 5.3
DB error in Contribution details report
September 30, 2014, 10:24:25 pm
Hi guys,

I'm using Civi 4.4 in Drupal 7. I have a group of users named 'Clients' at the Drupal side. For users in this group, they have the permission to access the CRM, but don't have the permission to view all contacts. I enable the 'Contribution details' report in Civicrm dashboard. However, I get a 'DB error: syntax error' in the page. Then I checked the logging messages to find the details and it provides some debugging messages saying:
Code: [Select]
Oct 01 12:10:47  [info] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] => CREATE TEMPORARY TABLE civireport_contribution_detail_temp2 AS SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, contact_civireport.id as civicrm_contact_id, contacthonor.id as civicrm_contact_honor_id_honor, contribution_civireport.id as civicrm_contribution_contribution_id, contribution_civireport.financial_type_id as civicrm_contribution_financial_type_id, contribution_civireport.currency as civicrm_contribution_currency, contribution_civireport.receive_date as civicrm_contribution_receive_date, sum(contribution_soft_civireport.amount) as civicrm_contribution_total_amount_sum, address_civireport.country_id as civicrm_address_country_id 
        FROM  civireport_contribution_detail_temp1 temp1_civireport
               INNER JOIN civicrm_contribution contribution_civireport
                       ON temp1_civireport.civicrm_contribution_contribution_id = contribution_civireport.id
               INNER JOIN civicrm_contribution_soft contribution_soft_civireport
                       ON contribution_soft_civireport.contribution_id = contribution_civireport.id
               INNER JOIN civicrm_contact      contact_civireport  INNER JOIN civicrm_acl_contact_cache aclContactCache ON contact_civireport.id = aclContactCache.contact_id
                       ON contact_civireport.id = contribution_soft_civireport.contact_id
            LEFT JOIN civicrm_address address_civireport
                   ON contact_civireport.id = address_civireport.contact_id AND
                      address_civireport.is_primary = 1

            LEFT JOIN civicrm_email email_civireport
                   ON contact_civireport.id = email_civireport.contact_id AND
                      email_civireport.is_primary = 1

            LEFT JOIN civicrm_contact contacthonor
                      ON contacthonor.id = contribution_civireport.honor_contact_id  GROUP BY contact_civireport.id, contribution_civireport.id  [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON contact_civireport.id = contribution_soft_civireport.contact_id
            L' at line 8]
    [type] => DB_Error
    [user_info] => CREATE TEMPORARY TABLE civireport_contribution_detail_temp2 AS SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, contact_civireport.id as civicrm_contact_id, contacthonor.id as civicrm_contact_honor_id_honor, contribution_civireport.id as civicrm_contribution_contribution_id, contribution_civireport.financial_type_id as civicrm_contribution_financial_type_id, contribution_civireport.currency as civicrm_contribution_currency, contribution_civireport.receive_date as civicrm_contribution_receive_date, sum(contribution_soft_civireport.amount) as civicrm_contribution_total_amount_sum, address_civireport.country_id as civicrm_address_country_id 
        FROM  civireport_contribution_detail_temp1 temp1_civireport
               INNER JOIN civicrm_contribution contribution_civireport
                       ON temp1_civireport.civicrm_contribution_contribution_id = contribution_civireport.id
               INNER JOIN civicrm_contribution_soft contribution_soft_civireport
                       ON contribution_soft_civireport.contribution_id = contribution_civireport.id
               INNER JOIN civicrm_contact      contact_civireport  INNER JOIN civicrm_acl_contact_cache aclContactCache ON contact_civireport.id = aclContactCache.contact_id
                       ON contact_civireport.id = contribution_soft_civireport.contact_id
            LEFT JOIN civicrm_address address_civireport
                   ON contact_civireport.id = address_civireport.contact_id AND
                      address_civireport.is_primary = 1

            LEFT JOIN civicrm_email email_civireport
                   ON contact_civireport.id = email_civireport.contact_id AND
                      email_civireport.is_primary = 1

            LEFT JOIN civicrm_contact contacthonor
                      ON contacthonor.id = contribution_civireport.honor_contact_id  GROUP BY contact_civireport.id, contribution_civireport.id  [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON contact_civireport.id = contribution_soft_civireport.contact_id
            L' at line 8]
    [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="CREATE TEMPORARY TABLE civireport_contribution_detail_temp2 AS SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, contact_civireport.id as civicrm_contact_id, contacthonor.id as civicrm_contact_honor_id_honor, contribution_civireport.id as civicrm_contribution_contribution_id, contribution_civireport.financial_type_id as civicrm_contribution_financial_type_id, contribution_civireport.currency as civicrm_contribution_currency, contribution_civireport.receive_date as civicrm_contribution_receive_date, sum(contribution_soft_civireport.amount) as civicrm_contribution_total_amount_sum, address_civireport.country_id as civicrm_address_country_id 
        FROM  civireport_contribution_detail_temp1 temp1_civireport
               INNER JOIN civicrm_contribution contribution_civireport
                       ON temp1_civireport.civicrm_contribution_contribution_id = contribution_civireport.id
               INNER JOIN civicrm_contribution_soft contribution_soft_civireport
                       ON contribution_soft_civireport.contribution_id = contribution_civireport.id
               INNER JOIN civicrm_contact      contact_civireport  INNER JOIN civicrm_acl_contact_cache aclContactCache ON contact_civireport.id = aclContactCache.contact_id
                       ON contact_civireport.id = contribution_soft_civireport.contact_id
            LEFT JOIN civicrm_address address_civireport
                   ON contact_civireport.id = address_civireport.contact_id AND
                      address_civireport.is_primary = 1

            LEFT JOIN civicrm_email email_civireport
                   ON contact_civireport.id = email_civireport.contact_id AND
                      email_civireport.is_primary = 1

            LEFT JOIN civicrm_contact contacthonor
                      ON contacthonor.id = contribution_civireport.honor_contact_id  GROUP BY contact_civireport.id, contribution_civireport.id  [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON contact_civireport.id = contribution_soft_civireport.contact_id
            L' at line 8]"]
)
It seems that the error is due to the wrong placement of a 'INNER JOIN' in here
Code: [Select]
INNER JOIN civicrm_contact      contact_civireport  INNER JOIN civicrm_acl_contact_cache aclContactCache ON contact_civireport.id = aclContactCache.contact_id
                       ON contact_civireport.id = contribution_soft_civireport.contact_id

I haven't change anything relevant to the report; so all the SQL query is generated from the Core files. Does anyone know how to fix this? or maybe some clues about the relevant files which generate this SQL query strings?

Thanks.

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: DB error in Contribution details report
October 01, 2014, 12:53:38 am
Which version in particular are you using?

A couple of things I can think of that you could do to help narrow down the problem...

1) Try and replicate on demo. I suspect the problem isn't there, but good to double check.

2) Check to see if the problem has been reported in the issue tracker (something like https://issues.civicrm.org/jira/issues/?jql=project%20%3D%20CRM%20AND%20affectedVersion%20in%20%284.4.0%2C%204.4.1%2C%204.4.2%2C%204.4.3%2C%204.4.4%2C%204.4.5%2C%204.4.6%2C%204.4.7%2C%204.5%29%20AND%20component%20%3D%20CiviReport) since if this is a core problem and it has been fixed, hopefully, you'll find it there.

3) you could diff between the master version and your version of this file: https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Form/Contribute/Detail.php
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

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: DB error in Contribution details report
October 01, 2014, 06:48:43 am

most likely this might be an issue with the report and how it integrates the ACL clause, so if it is still broken with michael's suggestion, check the php code for the report

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

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: DB error in Contribution details report
October 01, 2014, 07:18:35 am
What version of CiviCRM 4.4 are you using?  This looks identical to https://issues.civicrm.org/jira/browse/CRM-14085, which is fixed in versions 4.4.4 and above.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • DB error in Contribution details report

This forum was archived on 2017-11-26.