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

Create dynamic group fails with SELECT DISTINCT

    Details

    • Type: Bug
    • Status: Open
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: 4.6.12
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      as an example I use this custom search module :
      https://wiki.civicrm.org/confluence/display/CRMDOC/Custom+Search+Include+Exclude+Groups+and+Tags+with+and_or
      only modification :
      $tags =& CRM_Core_PseudoConstant::tag( );
      to
      $tags=0;#& CRM_Core_PseudoConstant::tag( );

      no problem for searching. but when I try to save the search I get a DB error.

      reading at the error; something has been inserted between the SELECT and the DISTINCT. Which is the cause of the SQL error.
      I got to the file /html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php(543) to see 20 lines before :

      if ($sql)

      { $sql = preg_replace("/^\s*SELECT/", "SELECT $groupID as group_id, ", $sql); }

      this bad regex inserting without knowledge of mysql syntax something between SELECT and DISTINCT is the root of the problem.

        Attachments

        1. error.txt
          9 kB
          Jean-Philippe Pialasse

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jppialasse Jean-Philippe Pialasse
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: