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

saving custom search as smart group produces back trace

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.2.2
    • Fix Version/s: 4.3.0
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      I took the following steps on demo.civicrm.org:

      Clicked Search -> Custom Searches

      Clicked "Find Contribution Amounts by Tag"

      Selected Date range: 10/10/2011 - 10/10/2012 (did not select a tag)

      Clicked Search

      One result found. Selected "New Smart Group" from actions

      Created a name for the new smart group (did not check email)

      Clicked "Save Smart Group"

      And I got this backtrace:

      backTrace

      #0 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Core/Error.php(148): CRM_Core_Error::backtrace()
      #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
      #2 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
      #3 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/DB.php(968): PEAR_Error->PEAR_Error("DB Error: syntax error", -2, 16, (Array:2), "INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT ...")
      #4 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/PEAR.php(564): DB_Error->DB_Error(-2, 16, (Array:2), "INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT ...")
      #5 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/DB/common.php(1903): PEAR->raiseError(NULL, -2, NULL, NULL, "INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT ...", "DB_Error", TRUE)
      #6 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/DB/mysql.php(898): DB_common->raiseError(-2, NULL, NULL, NULL, "1064 ** You have an error in your SQL syntax; check the manual that correspon...")
      #7 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/DB/mysql.php(327): DB_mysql->mysqlRaiseError()
      #8 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/DB/common.php(1216): DB_mysql->simpleQuery("INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT ...")
      #9 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/DB/DataObject.php(2421): DB_common->query("INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT ...")
      #10 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/DB/DataObject.php(1613): DB_DataObject->_query("INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT ...")
      #11 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Core/DAO.php(155): DB_DataObject->query("INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT ...")
      #12 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Core/DAO.php(922): CRM_Core_DAO->query("INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT ...", TRUE)
      #13 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/GroupContactCache.php(346): CRM_Core_DAO::executeQuery("INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT ...")
      #14 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/Query.php(2559): CRM_Contact_BAO_GroupContactCache::load(Object(CRM_Core_DAO))
      #15 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/Query.php(2526): CRM_Contact_BAO_Query->addGroupContactCache((Array:1))
      #16 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/Query.php(2503): CRM_Contact_BAO_Query->savedSearch((Array:5))
      #17 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/Query.php(1334): CRM_Contact_BAO_Query->group((Array:5))
      #18 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/Query.php(1529): CRM_Contact_BAO_Query->whereClauseSingle((Array:5))
      #19 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/Query.php(459): CRM_Contact_BAO_Query->whereClause()
      #20 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/Query.php(420): CRM_Contact_BAO_Query->initialize()
      #21 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/Query.php(2042): CRM_Contact_BAO_Query->__construct((Array:1), NULL, NULL, FALSE, FALSE)
      #22 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/Group.php(464): CRM_Contact_BAO_Query::getWhereClause((Array:1), NULL, (Array:0), (Array:0))
      #23 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/BAO/Group.php(370): CRM_Contact_BAO_Group->buildClause()
      #24 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Contact/Form/Task/SaveSearch.php(215): CRM_Contact_BAO_Group::create((Array:7))
      #25 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Core/Form.php(246): CRM_Contact_Form_Task_SaveSearch->postProcess()
      #26 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Core/StateMachine.php(159): CRM_Core_Form->mainProcess()
      #27 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Core/QuickForm/Action/Next.php(60): CRM_Core_StateMachine->perform(Object(CRM_Contact_Form_Task_SaveSearch), "next", "Next")
      #28 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Contact_Form_Task_SaveSearch), "next")
      #29 /var/www/drupal7.civicrm.org/svn/civicrm42/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Contact_Form_Task_SaveSearch), "next")
      #30 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Core/Controller.php(289): HTML_QuickForm_Page->handle("next")
      #31 /var/www/drupal7.civicrm.org/svn/civicrm42/CRM/Core/Invoke.php(228): CRM_Core_Controller->run((Array:4), (Array:0))
      #32 /var/www/drupal7.civicrm.org/svn/civicrm42/drupal/civicrm.module(500): CRM_Core_Invoke::invoke((Array:4))
      #33 [internal function](): civicrm_invoke("contact", "search", "custom")
      #34 /var/www/drupal7.civicrm.org/public/includes/menu.inc(516): call_user_func_array("civicrm_invoke", (Array:3))
      #35 /var/www/drupal7.civicrm.org/public/index.php(21): menu_execute_active_handler()
      #36

      {main}

      Sorry but we are not able to provide this at the moment.
      DB Error: syntax error
      Error Details
      Database Error Code: 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 'DISTINCT civicrm_contact.id as contact_id FROM civicrm_contribution, ' at line 1, 1064
      Additional Details:

      Array
      (
      [callback] => Array
      (
      [0] => CRM_Core_Error
      [1] => handle
      )

      [code] => -2
      [message] => DB Error: syntax error
      [mode] => 16
      [debug_info] => INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT 6 as group_id, DISTINCT civicrm_contact.id as contact_id
      FROM
      civicrm_contribution,
      civicrm_contact
      LEFT JOIN civicrm_entity_tag ON ( civicrm_entity_tag.entity_table = 'civicrm_contact' AND
      civicrm_entity_tag.entity_id = civicrm_contact.id )
      LEFT JOIN civicrm_tag ON civicrm_tag.id = civicrm_entity_tag.tag_id

      WHERE civicrm_contact.contact_type = 'Individual' AND civicrm_contribution.contact_id = civicrm_contact.id AND civicrm_contribution.receive_date >= 20111010000000 AND civicrm_contribution.receive_date <= 20121010000000 AND civicrm_entity_tag.tag_id IS NOT NULL
      GROUP BY civicrm_contact.id
      AND contact_a.id NOT IN (
      SELECT contact_id FROM civicrm_group_contact
      WHERE civicrm_group_contact.status = 'Removed'
      AND civicrm_group_contact.group_id = 6 ) ); [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 'DISTINCT civicrm_contact.id as contact_id
      FROM
      civicrm_contribution,
      ' at line 1]
      [type] => DB_Error
      [user_info] => INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT 6 as group_id, DISTINCT civicrm_contact.id as contact_id
      FROM
      civicrm_contribution,
      civicrm_contact
      LEFT JOIN civicrm_entity_tag ON ( civicrm_entity_tag.entity_table = 'civicrm_contact' AND
      civicrm_entity_tag.entity_id = civicrm_contact.id )
      LEFT JOIN civicrm_tag ON civicrm_tag.id = civicrm_entity_tag.tag_id

      WHERE civicrm_contact.contact_type = 'Individual' AND civicrm_contribution.contact_id = civicrm_contact.id AND civicrm_contribution.receive_date >= 20111010000000 AND civicrm_contribution.receive_date <= 20121010000000 AND civicrm_entity_tag.tag_id IS NOT NULL
      GROUP BY civicrm_contact.id
      AND contact_a.id NOT IN (
      SELECT contact_id FROM civicrm_group_contact
      WHERE civicrm_group_contact.status = 'Removed'
      AND civicrm_group_contact.group_id = 6 ) ); [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 'DISTINCT civicrm_contact.id as contact_id
      FROM
      civicrm_contribution,
      ' at line 1]
      [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (SELECT 6 as group_id, DISTINCT civicrm_contact.id as contact_id
      FROM
      civicrm_contribution,
      civicrm_contact
      LEFT JOIN civicrm_entity_tag ON ( civicrm_entity_tag.entity_table = 'civicrm_contact' AND
      civicrm_entity_tag.entity_id = civicrm_contact.id )
      LEFT JOIN civicrm_tag ON civicrm_tag.id = civicrm_entity_tag.tag_id

      WHERE civicrm_contact.contact_type = 'Individual' AND civicrm_contribution.contact_id = civicrm_contact.id AND civicrm_contribution.receive_date >= 20111010000000 AND civicrm_contribution.receive_date <= 20121010000000 AND civicrm_entity_tag.tag_id IS NOT NULL
      GROUP BY civicrm_contact.id
      AND contact_a.id NOT IN (
      SELECT contact_id FROM civicrm_group_contact
      WHERE civicrm_group_contact.status = 'Removed'
      AND civicrm_group_contact.group_id = 6 ) ); [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 'DISTINCT civicrm_contact.id as contact_id
      FROM
      civicrm_contribution,
      ' at line 1]"]
      )

        Attachments

          Activity

            People

            • Assignee:
              jamie Jamie McClelland
              Reporter:
              jamie Jamie McClelland
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: