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

Fatal error on membership page if membership status 'Cancelled' is disabled

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.5.2
    • Fix Version/s: 4.5.3
    • Component/s: None
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      On upgrading to 4.5.2 a previously-working membership page started failing with the error which appears to be a regression introduced in CRM-14645.

      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 ') ) AND ( civicrm_membership.contact_id = 1 ) AND ( civicrm_membership.members' at line 4, 1064
      Additional Details:

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

      [code] => -2
      [message] => DB Error: syntax error
      [mode] => 16
      [debug_info] => SELECT *
      FROM civicrm_membership

      WHERE ( is_test IS NULL OR is_test = 0 ) AND ( status_id NOT IN ( 5,) ) AND ( civicrm_membership.contact_id = 1 ) AND ( civicrm_membership.membership_type_id = 1 )

      ORDER BY start_date DESC

      based on the call to the function

      civicrm/CRM/Price/BAO/PriceSet.php(959): CRM_Member_BAO_Membership::getContactMembership("1", "1", FALSE)

      The code lines are

      //avoid pending membership as current membership: CRM-3027
      $statusIds[] = array_search('Pending', CRM_Member_PseudoConstant::membershipStatus());
      if (!$membershipId)

      { $statusIds[] = array_search('Cancelled', CRM_Member_PseudoConstant::membershipStatus()); }

      $dao->whereAdd('status_id NOT IN ( ' . implode(',', $statusIds) . ')');

      And the problem is that if the Cancelled status has been disabled the array looks like

      array (5, NULL);
      which results in a clause like 'IN (5,)

      which is invalid SQL

      I originally thought it might not be valid to disabled the cancelled status & it should be reserved - but perhaps the above lines should just be fixed so that the syntax error doesn't happen

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                yashodha Yashodha Chaku
                Reporter:
                eileen Eileen McNaughton
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours
                  4h