CRM-8827 Exporting contributions does not export all found records due to erroneous group by statement

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 3.4.5
    • Fix Version/s: 3.4.6
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      When attempting to export contributions not all records are exported. For example, you may search for all contributions received this year and the interface tells yous that there are 1,803 records. When exporting, the CSV file contains many less records than the number indicated. Since I don't fully understand all the new code relating to exporting records I'll give an idea of where the problem may lay and leave it to a developer more familiar with the code to actually implement a fix. The following flow, of course, is only relative to my contribution search and particular parameters, so many not apply in every case, but at least in some:

      In CRM/Contact/BAO/Query.php on line 3424 $this->_useDistinct is set to true in the function searchQuery(). From inside searchQuery() the function query() is called, and on line 1115 if _useDistinct is set (along with another parameter) then $this->_useGroupBy gets set to true. The problem is apparently the GROUP BY statement getting added to the query. This causes problems in the output because we have many users who contribute many times in a year (recurring), so grouping on contact ID seems to be removing all contributions from the same person, except for 1, of course.

        Attachments

          Activity

          [CRM-8827] Exporting contributions does not export all found records due to erroneous group by statement
          Nathan Kinkade added a comment -

          For some reason I can't seem to replicate this problem with a small sample set of data on the demo site. The environments are different though, and perhaps it has to do with the fact that $permission is set in our environment, but not in the environment of the demo site????

          3420 // regenerate fromClause since permission might have added tables
          3421 if ( $permission ) {
          3422 //fix for row count in qill (in contribute/membership find)
          3423 if (! $count )

          { 3424 $this->_useDistinct = true; 3425 }

          3426 $this->_fromClause = self::fromClause( $this->_tables , null, null, $this->_primaryLocation, $this->_mode );
          3427 $this->_simpleFromClause = self::fromClause( $this->_whereTables, null, null, $this->_primaryLocation, $this->_mode );
          3428 }

          Nathan Kinkade added a comment -

          This bug seems to have been a duplicate of CRM-8572. Sorry for not browsing existing bugs thoroughly enough. I did search, but for some reason CRM-8572 escaped my eye. This ticket can be closed as a duplicate.

          I applied the patch from r35598 and it fixed the issue, mostly. I say mostly because now the contribution export page says there are 1803 records, yet the CSV file contains 1827 records. I don't know if that is a separate issue worth investigating.

          Donald A. Lobo added a comment -

            People

            • Assignee:
              Donald A. Lobo
              Reporter:
              Nathan Kinkade

              Dates

              • Created:
                Updated:
                Resolved: