From: eileen Date: Mon, 2 Sep 2019 22:50:37 +0000 (+1200) Subject: Fix failure to save relative dates on legacy fields X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f37a3b9510fcaa5b49260e3e5f366cb3e17eb8e5;p=civicrm-core.git Fix failure to save relative dates on legacy fields --- diff --git a/CRM/Contact/BAO/SavedSearch.php b/CRM/Contact/BAO/SavedSearch.php index 19942540c5..4037b82856 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -437,9 +437,29 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ // This is required only until all fields are converted to datepicker fields as the new format is truer to the // form format and simply saves (e.g) custom_3_relative => "this.year" $relativeDates = ['relative_dates' => []]; - $specialDateFields = ['event_relative', 'case_from_relative', 'case_to_relative', 'participant_relative', 'log_date_relative']; + $specialDateFields = [ + 'event_relative', + 'case_from_relative', + 'case_to_relative', + 'participant_relative', + 'log_date_relative', + 'pledge_payment_date_relative', + 'pledge_start_date_relative', + 'pledge_end_date_relative', + 'pledge_create_date_relative', + 'member_join_date_relative', + 'member_start_date_relative', + 'member_end_date_relative', + 'birth_date_relative', + 'deceased_date_relative', + 'mailing_date_relative', + 'relation_date_relative', + 'relation_start_date_relative', + 'relation_end_date_relative', + 'relation_action_date_relative', + ]; foreach ($formValues as $id => $value) { - if ((preg_match('/_date$/', $id) || in_array($id, $specialDateFields)) && !empty($value)) { + if (in_array($id, $specialDateFields) && !empty($value)) { $entityName = strstr($id, '_date', TRUE); if (empty($entityName)) { $entityName = strstr($id, '_relative', TRUE); diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index 5422b5223c..46efb5e8b7 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -945,7 +945,7 @@ class api_v3_EventTest extends CiviUnitTestCase { ]); $eventResult = $this->callAPISuccess('Event', 'getsingle', ['id' => $eventResult['id']]); foreach ($templateParams as $param => $value) { - $this->assertEquals($value, $eventResult[$param]); + $this->assertEquals($value, $eventResult[$param], print_r($eventResult, 1)); } }