CRM-6277 Expired membership end date resets to November 2001

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Critical
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.1.4
    • Fix Version/s: 3.1.6
    • Component/s: CiviMember
    • Labels:
      None

      Description

      When an expired member renews their membership through a contribution page, the membership end date changes to November 2001 regardless of the members real start/end date. This requires the administrator to manually set the proper end date.

      With a clean 3.1.4 install, edit the default 'Member Signup and Renewal' form as follows:

      • disable execute real time transactions
      • enable contribution amounts section
      • enable allow other amounts

      Edit your Membership from the contact summary page and add a General membership with a start date and end date in the past (expired).

      Now access the live page, make a contribution for General membership, continue, continue.

      Now access the contact page and view your General membership. It's still listed as expired and the end date is November 2001.

      After talking with DGG and debugging on a local copy, one possible fix would be:

      CRM/Member/BAO/MembershipType.php
      506c506
      > $today = date('Ymd');

      < $today = CRM_Utils_Date::processDate( $changeToday, null, false, 'Ymd' );

      $changeToday is null when passed into processDate(), which means $today is null when returned.

      From IRC
      [12:15] <dgg> CRM/Contribute/Contribution/Confirm.php postProcess which calls CRM/Member/BAO/Membership postProcessMembership() function. The bug is prob in renewMembership() in that same BAO file - check for the condition where currentMembership[is_current_member] is false - starting around line 1157

        Attachments

          Activity

          [CRM-6277] Expired membership end date resets to November 2001
          Sushant Paste added a comment -

          Tested in r27863

          Dharmatech added a comment -

          Verified, thanks.

          Patches listed below (Membership.php and MembershipStatus.php) will backport the fix to CiviCRM 3.1.5 for anyone that needs it.

          — Membership.php.orig 2010-05-25 15:48:15.000000000 -0600
          +++ Membership.php 2010-05-25 15:51:03.000000000 -0600
          @@ -1147,18 +1147,23 @@
          $membership->find(true);
          return $membership;
          }

          • +
            + //we might renew expired membership, CRM-6277
            + if ( !$changeToday )

            Unknown macro: {+ if ( $form->get( 'renewDate' ) ) { + $changeToday = $form->get( 'renewDate' ); + } else if ( get_class( $form ) == 'CRM_Contribute_Form_Contribution_Confirm' ) { + $changeToday = date( 'YmdHis' ); + }+ }

            +
            // Check and fix the membership if it is STALE
            self::fixMembershipStatusBeforeRenew( $currentMembership, $changeToday );

          • +
            // Now Renew the membership
            if ( ! $currentMembership['is_current_member'] ) {
            // membership is not CURRENT

          • if ( $form->get( 'renewDate' ) ) { - $changeToday = $form->get( 'renewDate' ); - }
          • $dates =
            CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType( $currentMembership['id'],
            $changeToday );
            @@ -1318,7 +1323,11 @@
            */
            static function fixMembershipStatusBeforeRenew( &$currentMembership, $changeToday )
            {

          • $today = CRM_Utils_Date::getToday( $changeToday );
            + $today = null;
            + if ( $changeToday ) { + $today = CRM_Utils_Date::processDate( $changeToday, null, false, 'Y-m-d' ); + }

            +
            require_once 'CRM/Member/BAO/MembershipStatus.php';
            $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate(
            $currentMembership['start_date'],
            @@ -1661,4 +1670,4 @@
            $query = "SELECT count FROM civicrm_membership WHERE civicrm_membership.contact_id = {$contactID} AND civicrm_membership.is_test = 0 ";
            return CRM_Core_DAO::singleValueQuery( $query );
            }
            -}
            \ No newline at end of file
            +}

          — MembershipStatus.php.orig 2010-05-25 15:49:09.000000000 -0600
          +++ MembershipStatus.php 2010-05-25 15:49:53.000000000 -0600
          @@ -194,7 +194,7 @@
          static function getMembershipStatusByDate( $startDate, $endDate, $joinDate, $statusDate = 'today', $excludeIsAdmin = false )
          {
          $membershipDetails = array();

          • if ( $statusDate == 'today' ) {
            + if ( !$statusDate || $statusDate == 'today' ) {
            $statusDate = getDate();
            $statusDate = date( 'Ymd',
            mktime( $statusDate['hours'],

            People

            • Assignee:
              Sushant Paste
              Reporter:
              Dharmatech

              Dates

              • Created:
                Updated:
                Resolved: