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

If a Contribution Page has a free Membership (zero amount) and the Pay Later option is enabled then "DB Error: syntax error" is shown when the Contribution is submitted if an INVOICE is to be rendered

    Details

    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      User and Admin Doc
    • Funding Source:
      Needs Funding

      Description

      If a Contribution Page has a free Membership and the pay later option is enabled then "DB Error: syntax error" is shown when the Contribution is submitted.

      To reproduce:
      1. Create a Price Set for Memberships which has a Membership Type with a zero amount ($0)
      2. Create a Contribution page
      3. Amounts, disable the "CONTRIBUTION AMOUNTS SECTION ENABLED" option
      4. Amounts, enable the "PAY LATER OPTION" and set a pay later message
      5. Memberships, check the "Membership Section Enabled?"
      6. Memberships, select the "Membership Price Set" with the zero membership fee (step 1).
      7. Memberships, enable the "Require Membership Signup" option
      8. Live Test the contribution page
      9. Submit the Contribution.
      10. White screen is displayed with the error, "DB Error: syntax error"

      The solution in this case is to disable the Amounts, "PAY LATER OPTION". Then the contribution page submits without error.

      It would be good to either inform the user when editing the Contribution page to not use this option, hide this option entirely and/or fix the database error that is raised. Documentation would be good, however less likely to be read.

      CiviCRM error log output is below.
      {{Mar 01 17:50:02 [info] $Fatal Error Details = Array
      (
      [callback] => Array
      (
      [0] => CRM_Core_Error
      [1] => handle
      )

      [code] => -2
      [message] => DB Error: syntax error
      [mode] => 16
      [debug_info] =>
      SELECT c.id as contribution_id,
      c.contact_id as contact_id ,
      mp.membership_id as membership_id ,
      pp.participant_id as participant_id ,
      p.event_id as event_id
      FROM civicrm_contribution c
      LEFT JOIN civicrm_membership_payment mp ON mp.contribution_id = c.id
      LEFT JOIN civicrm_participant_payment pp ON pp.contribution_id = c.id
      LEFT JOIN civicrm_participant p ON pp.participant_id = p.id
      WHERE c.id IN ( ) [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 ')' at line 10]
      [type] => DB_Error
      [user_info] =>
      SELECT c.id as contribution_id,
      c.contact_id as contact_id ,
      mp.membership_id as membership_id ,
      pp.participant_id as participant_id ,
      p.event_id as event_id
      FROM civicrm_contribution c
      LEFT JOIN civicrm_membership_payment mp ON mp.contribution_id = c.id
      LEFT JOIN civicrm_participant_payment pp ON pp.contribution_id = c.id
      LEFT JOIN civicrm_participant p ON pp.participant_id = p.id
      WHERE c.id IN ( ) [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 ')' at line 10]
      [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="
      SELECT c.id as contribution_id,
      c.contact_id as contact_id ,
      mp.membership_id as membership_id ,
      pp.participant_id as participant_id ,
      p.event_id as event_id
      FROM civicrm_contribution c
      LEFT JOIN civicrm_membership_payment mp ON mp.contribution_id = c.id
      LEFT JOIN civicrm_participant_payment pp ON pp.contribution_id = c.id
      LEFT JOIN civicrm_participant p ON pp.participant_id = p.id
      WHERE c.id IN ( ) [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 ')' at line 10]"]
      )

      Mar 01 17:50:02 [info] $backTrace = #0 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/Error.php(235): CRM_Core_Error::backtrace("backTrace", TRUE)
      #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
      #2 /home/demo/public_html/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
      #3 /home/demo/public_html/sites/all/modules/civicrm/packages/DB.php(976): PEAR_Error->PEAR_Error("DB Error: syntax error", -2, 16, (Array:2), "\nSELECT c.id as contribution_id,\n c.contact_id ...")
      #4 /home/demo/public_html/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-2, 16, (Array:2), "\nSELECT c.id as contribution_id,\n c.contact_id ...")
      #5 /home/demo/public_html/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -2, NULL, NULL, "\nSELECT c.id as contribution_id,\n c.contact_id ...", "DB_Error", TRUE)
      #6 /home/demo/public_html/sites/all/modules/civicrm/packages/DB/mysql.php(895): DB_common->raiseError(-2, NULL, NULL, NULL, "1064 ** You have an error in your SQL syntax; check the manual that correspon...")
      #7 /home/demo/public_html/sites/all/modules/civicrm/packages/DB/mysql.php(328): DB_mysql->mysqlRaiseError()
      #8 /home/demo/public_html/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("\nSELECT c.id as contribution_id,\n c.contact_id ...")
      #9 /home/demo/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php(2442): DB_common->query("\nSELECT c.id as contribution_id,\n c.contact_id ...")
      #10 /home/demo/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php(1634): DB_DataObject->_query("\nSELECT c.id as contribution_id,\n c.contact_id ...")
      #11 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php(321): DB_DataObject->query("\nSELECT c.id as contribution_id,\n c.contact_id ...")
      #12 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php(1180): CRM_Core_DAO->query("\nSELECT c.id as contribution_id,\n c.contact_id ...", TRUE)
      #13 /home/demo/public_html/sites/all/modules/civicrm/CRM/Contribute/Form/Task/Status.php(322): CRM_Core_DAO::executeQuery("\nSELECT c.id as contribution_id,\n c.contact_id ...", (Array:0))
      #14 /home/demo/public_html/sites/all/modules/civicrm/CRM/Contribute/Form/Task/PDF.php(256): CRM_Contribute_Form_Task_Status::getDetails("")
      #15 /home/demo/public_html/sites/all/modules/civicrm/CRM/Contribute/Form/Task/Invoice.php(252): CRM_Contribute_Form_Task_PDF::getElements((Array:1), (Array:2), (Array:1))
      #16 /home/demo/public_html/sites/all/modules/civicrm/CRM/Contribute/BAO/ContributionPage.php(954): CRM_Contribute_Form_Task_Invoice::printPDF((Array:1), (Array:2), (Array:1), NULL)
      #17 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/BAO/MessageTemplate.php(508): CRM_Contribute_BAO_ContributionPage::addInvoicePdfToEmail(NULL, "6200")
      #18 /home/demo/public_html/sites/all/modules/civicrm/CRM/Contribute/BAO/ContributionPage.php(428): CRM_Core_BAO_MessageTemplate::sendTemplate((Array:13))
      #19 /home/demo/public_html/sites/all/modules/civicrm/CRM/Member/BAO/Membership.php(1484): CRM_Contribute_BAO_ContributionPage::sendMail("6200", (Array:34), FALSE, FALSE, (Array:0))
      #20 /home/demo/public_html/sites/all/modules/civicrm/CRM/Contribute/Form/Contribution/Confirm.php(1914): CRM_Member_BAO_Membership::postProcessMembership((Array:34), "6200", Object(CRM_Contribute_Form_Contribution_Confirm), (Array:31), (Array:0), (Array:0), (Array:11), (Array:1), TRUE, NULL, FALSE, "6", (Array:0), TRUE)
      #21 /home/demo/public_html/sites/all/modules/civicrm/CRM/Contribute/Form/Contribution/Confirm.php(1023): CRM_Contribute_Form_Contribution_Confirm->processMembership((Array:34), "6200", (Array:0), (Array:0), (Array:31), (Array:0), TRUE)
      #22 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/Form.php(345): CRM_Contribute_Form_Contribution_Confirm->postProcess()
      #23 /home/demo/public_html/sites/all/modules/civicrm/CRM/Contribute/Form/Contribution/Main.php(1394): CRM_Core_Form->mainProcess()
      #24 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/Form.php(345): CRM_Contribute_Form_Contribution_Main->postProcess()
      #25 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(166): CRM_Core_Form->mainProcess()
      #26 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(133): CRM_Core_QuickForm_Action_Upload->realPerform(Object(CRM_Contribute_Form_Contribution_Main), "upload")
      #27 /home/demo/public_html/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload->perform(Object(CRM_Contribute_Form_Contribution_Main), "upload")
      #28 /home/demo/public_html/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Contribute_Form_Contribution_Main), "upload")
      #29 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/Controller.php(353): HTML_QuickForm_Page->handle("upload")
      #30 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(312): CRM_Core_Controller->run((Array:3), NULL)
      #31 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem((Array:15))
      #32 /home/demo/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke((Array:3))
      #33 /home/demo/public_html/sites/all/modules/civicrm/drupal/civicrm.module(489): CRM_Core_Invoke::invoke((Array:3))
      #34 [internal function](): civicrm_invoke("contribute", "transact")
      #35 /home/demo/public_html/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:2))
      #36 /home/demo/public_html/index.php(21): menu_execute_active_handler()
      #37

      {main}

      }}

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              agileware Agileware
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: