(REF) CRM/Member - Change strtotime() to CRM_Utils_Time::strtotime()
authorTim Otten <totten@civicrm.org>
Sat, 2 Jan 2021 06:20:56 +0000 (22:20 -0800)
committerTim Otten <totten@civicrm.org>
Fri, 8 Jan 2021 05:24:46 +0000 (21:24 -0800)
CRM/Member/BAO/Membership.php
CRM/Member/BAO/MembershipStatus.php
CRM/Member/Form/Membership.php
CRM/Member/Form/MembershipRenewal.php

index 01086e0f886387e1679fb9c4ee56c00bfd7b4217..ada6d3cd31a580b181afdc305a6a7fbe31bdf152 100644 (file)
@@ -252,8 +252,8 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership {
     if (empty($params['is_override']) && empty($params['skipStatusCal'])) {
       $fieldsToLoad = [];
       foreach (['start_date', 'end_date', 'join_date'] as $dateField) {
-        if (!empty($params[$dateField]) && $params[$dateField] !== 'null' && strpos($params[$dateField], date('Ymd', strtotime(trim($params[$dateField])))) !== 0) {
-          $params[$dateField] = date('Ymd', strtotime(trim($params[$dateField])));
+        if (!empty($params[$dateField]) && $params[$dateField] !== 'null' && strpos($params[$dateField], date('Ymd', CRM_Utils_Time::strtotime(trim($params[$dateField])))) !== 0) {
+          $params[$dateField] = date('Ymd', CRM_Utils_Time::strtotime(trim($params[$dateField])));
           // @todo enable this once core is using the api.
           // CRM_Core_Error::deprecatedWarning('Relying on the BAO to clean up dates is deprecated. Call membership create via the api');
         }
@@ -1012,7 +1012,7 @@ INNER JOIN  civicrm_membership_type type ON ( type.id = membership.membership_ty
     $dates = ['startDate', 'endDate'];
     foreach ($dates as $date) {
       if (strlen($$date) === 8) {
-        $$date = date('Y-m-d', strtotime($$date));
+        $$date = date('Y-m-d', CRM_Utils_Time::strtotime($$date));
       }
     }
 
@@ -1200,7 +1200,7 @@ AND civicrm_membership.is_test = %2";
           $currentMembership['end_date'],
           $format
         ),
-        'modified_date' => date('Y-m-d H:i:s', strtotime($today)),
+        'modified_date' => date('Y-m-d H:i:s', CRM_Utils_Time::strtotime($today)),
         'membership_type_id' => $currentMembership['membership_type_id'],
         'max_related' => $currentMembership['max_related'] ?? 0,
       ];
@@ -2102,7 +2102,7 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND
    */
   protected static function matchesRequiredMembership($params, $membership) {
     foreach (['start_date', 'end_date'] as $date) {
-      if (strtotime($params[$date]) !== strtotime($membership[$date])) {
+      if (CRM_Utils_Time::strtotime($params[$date]) !== CRM_Utils_Time::strtotime($membership[$date])) {
         return FALSE;
       }
       if ((int) $params['status_id'] !== (int) $membership['status_id']) {
@@ -2714,7 +2714,7 @@ WHERE {$whereClause}";
       }
 
       $today = time();
-      if ($deceasedDate && strtotime($deceasedDate) > $today) {
+      if ($deceasedDate && CRM_Utils_Time::strtotime($deceasedDate) > $today) {
         return $updateMembershipMsg;
       }
 
index dd3404405dcfe5055c25b088e271597147a80f80..026b133062ccb886f0ea9ad4e9ca0a0884082691 100644 (file)
@@ -218,7 +218,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
       CRM_Core_Error::deprecatedFunctionWarning('pass now rather than today in');
     }
 
-    $statusDate = date('Ymd', strtotime($statusDate));
+    $statusDate = date('Ymd', CRM_Utils_Time::strtotime($statusDate));
 
     //fix for CRM-3570, if we have statuses with is_admin=1,
     //exclude these statuses from calculatation during import.
@@ -236,9 +236,9 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
     $membershipStatus = CRM_Core_DAO::executeQuery($query);
 
     $dates = [
-      'start' => ($startDate && $startDate !== 'null') ? date('Ymd', strtotime($startDate)) : '',
-      'end' => ($endDate && $endDate !== 'null') ? date('Ymd', strtotime($endDate)) : '',
-      'join' => ($joinDate && $joinDate !== 'null') ? date('Ymd', strtotime($joinDate)) : '',
+      'start' => ($startDate && $startDate !== 'null') ? date('Ymd', CRM_Utils_Time::strtotime($startDate)) : '',
+      'end' => ($endDate && $endDate !== 'null') ? date('Ymd', CRM_Utils_Time::strtotime($endDate)) : '',
+      'join' => ($joinDate && $joinDate !== 'null') ? date('Ymd', CRM_Utils_Time::strtotime($joinDate)) : '',
     ];
 
     while ($membershipStatus->fetch()) {
@@ -253,9 +253,9 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
             if ($membershipStatus->{$eve . '_event_adjust_unit'} &&
               $membershipStatus->{$eve . '_event_adjust_interval'}
             ) {
-              $month = date('m', strtotime($date));
-              $day = date('d', strtotime($date));
-              $year = date('Y', strtotime($date));
+              $month = date('m', CRM_Utils_Time::strtotime($date));
+              $day = date('d', CRM_Utils_Time::strtotime($date));
+              $year = date('Y', CRM_Utils_Time::strtotime($date));
               // add in months
               if ($membershipStatus->{$eve . '_event_adjust_unit'} === 'month') {
                 ${$eve . 'Event'} = date('Ymd', mktime(0, 0, 0,
index 4988331a0ecc6bed640acc6ed0bc935f5b95e0b7..a9008897def03067441a79fcf6912580b7ceb3dd 100644 (file)
@@ -1966,7 +1966,7 @@ DESC limit 1");
 
     $recurParams['start_date'] = $recurParams['create_date'] = $recurParams['modified_date'] = date('YmdHis');
     if (!empty($params['receive_date'])) {
-      $recurParams['start_date'] = date('YmdHis', strtotime($params['receive_date']));
+      $recurParams['start_date'] = date('YmdHis', CRM_Utils_Time::strtotime($params['receive_date']));
     }
     $recurParams['invoice_id'] = $params['invoiceID'] ?? NULL;
     $recurParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
index cffc53edfc67f8e45828aa1f999a02c1913e6d21..d2f65ecaebc56c69f5e33a425ba73b28dcc49be1 100644 (file)
@@ -737,7 +737,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
     ])) {
       return CRM_Member_BAO_Membership::create($memParams);
     }
-    $memParams['join_date'] = date('Ymd', strtotime($currentMembership['join_date']));
+    $memParams['join_date'] = date('Ymd', CRM_Utils_Time::strtotime($currentMembership['join_date']));
     $isMembershipCurrent = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $currentMembership['status_id'], 'is_current_member');
 
     // CRM-7297 Membership Upsell - calculate dates based on new membership type