Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-8455

Incorrect SQL syntax in Export.php WHERE clause causes Export to hang

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.3.6, 3.4.4, 4.0.4
    • Fix Version/s: 3.4.5
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      In CRM/Export/BAO/Export.php, there is a set of lines creating a WHERE clause that don't have parenthesis in the right place. So the query runs an OR clause, causing all records from civicrm_group_contact to be queried for every contact returned. If civicrm_group_contact has many rows, it will hang the query for a while.

      Here are the two lines in question (only the 2nd line needs changing). In 3.4.4 and 4.0.4, this is line 455 and 456. In 3.2.5, it's 414/415:
      $oldClause = "contact_a.id = civicrm_group_contact.contact_id";
      $newClause = " ( $oldClause AND civicrm_group_contact.status = 'Added' OR civicrm_group_contact.status IS NULL ) ";

      The second line should be something like this instead:
      $newClause = " ( $oldClause AND (civicrm_group_contact.status = 'Added' OR civicrm_group_contact.status IS NULL) ) ";
      --with the parens around the two status clauses

      Sorry, I wasn't sure if a patch file was needed due to it being a one-line change (and not sure which version to work off since we're on an old version still).

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              pbarmak Paul B
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: