From bb6cfada889305405c3e2566572723f6d81bf8af Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 20 Mar 2023 19:07:05 +1300 Subject: [PATCH] Remove do-nothing formatting code I've been convinced that dates are already handled long before this point (& loading from the database) so nearly a year ago I added deprecation notices to fire if this code ever actually did anything. No reports. It can go: --- CRM/Contact/BAO/Individual.php | 92 ---------------------------------- 1 file changed, 92 deletions(-) diff --git a/CRM/Contact/BAO/Individual.php b/CRM/Contact/BAO/Individual.php index 43ea780a7a..9c23f97923 100644 --- a/CRM/Contact/BAO/Individual.php +++ b/CRM/Contact/BAO/Individual.php @@ -248,98 +248,6 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_Contact { } } - $format = CRM_Utils_Date::getDateFormat('birth'); - if ($date = CRM_Utils_Array::value('birth_date', $params)) { - if (in_array($format, [ - 'dd-mm', - 'mm/dd', - ])) { - $separator = '/'; - if ($format == 'dd-mm') { - $separator = '-'; - } - $date = $date . $separator . '1902'; - } - elseif (in_array($format, [ - 'yy-mm', - ])) { - $date = $date . '-01'; - } - elseif (in_array($format, [ - 'M yy', - ])) { - $date = $date . '-01'; - } - elseif (in_array($format, [ - 'yy', - ])) { - $date = $date . '-01-01'; - } - $processedDate = CRM_Utils_Date::processDate($date); - $existing = substr(str_replace('-', '', $contact->birth_date), 0, 8) . '000000'; - // By adding this check here we can rip out this whole routine in a few - // months after confirming it actually does nothing, ever. - if ($existing !== $processedDate) { - CRM_Core_Error::deprecatedWarning('birth_date formatting should happen before BAO is hit'); - $contact->birth_date = $processedDate; - } - } - elseif ($contact->birth_date) { - if ($contact->birth_date !== CRM_Utils_Date::isoToMysql($contact->birth_date)) { - CRM_Core_Error::deprecatedWarning('birth date formatting should happen before BAO is hit'); - } - $contact->birth_date = CRM_Utils_Date::isoToMysql($contact->birth_date); - } - - if ($date = CRM_Utils_Array::value('deceased_date', $params)) { - if (in_array($format, [ - 'dd-mm', - 'mm/dd', - ])) { - $separator = '/'; - if ($format == 'dd-mm') { - $separator = '-'; - } - $date = $date . $separator . '1902'; - } - elseif (in_array($format, [ - 'yy-mm', - ])) { - $date = $date . '-01'; - } - elseif (in_array($format, [ - 'M yy', - ])) { - $date = $date . '-01'; - } - elseif (in_array($format, [ - 'yy', - ])) { - $date = $date . '-01-01'; - } - $processedDate = CRM_Utils_Date::processDate($date); - $existing = substr(str_replace('-', '', $contact->deceased_date), 0, 8) . '000000'; - // By adding this check here we can rip out this whole routine in a few - // months after confirming it actually does nothing, ever. - if ($existing !== $processedDate) { - CRM_Core_Error::deprecatedWarning('deceased formatting should happen before BAO is hit'); - } - $contact->deceased_date = CRM_Utils_Date::processDate($date); - } - elseif ($contact->deceased_date) { - if ($contact->deceased_date !== CRM_Utils_Date::isoToMysql($contact->deceased_date)) { - CRM_Core_Error::deprecatedWarning('deceased date formatting should happen before BAO is hit'); - } - $contact->deceased_date = CRM_Utils_Date::isoToMysql($contact->deceased_date); - } - - if ($middle_name = CRM_Utils_Array::value('middle_name', $params)) { - if ($middle_name !== $contact->middle_name) { - CRM_Core_Error::deprecatedWarning('random magic is deprecated - how could this be true'); - } - $contact->middle_name = $middle_name; - } - return $contact; } -- 2.25.1