X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FGeneric%2FUpdate.php;h=f983ba4b76dabee08bf6b26316009fb7db4cdbdc;hb=f299f7db79fed6f3598c84302966bda087e7cac3;hp=d982f0742659bb9fa5b4540417e4006ffddc3152;hpb=7481d51b832ba89932216bcc67bedbc17d7fc651;p=civicrm-core.git diff --git a/api/v3/Generic/Update.php b/api/v3/Generic/Update.php index d982f07426..f983ba4b76 100644 --- a/api/v3/Generic/Update.php +++ b/api/v3/Generic/Update.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2019 | + | Copyright CiviCRM LLC (c) 2004-2020 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -64,7 +64,7 @@ function civicrm_api3_generic_update($apiRequest) { if (strtolower($apiRequest['entity']) == 'contribution') { return civicrm_api($apiRequest['entity'], 'create', $apiRequest['params']); } - $seek = array($key_id => $apiRequest['params'][$key_id], 'version' => $apiRequest['version']); + $seek = [$key_id => $apiRequest['params'][$key_id], 'version' => $apiRequest['version']]; $existing = civicrm_api($apiRequest['entity'], 'get', $seek); if ($existing['is_error']) { return $existing; @@ -77,6 +77,12 @@ function civicrm_api3_generic_update($apiRequest) { } $existing = array_pop($existing['values']); + // Per Unit test testUpdateHouseholdWithAll we don't want to load these from the DB + // if they are not passed in then we'd rather they are calculated. + // Note update is not recomended anyway... + foreach (['sort_name', 'display_name'] as $fieldToNotSet) { + unset($existing[$fieldToNotSet]); + } $p = array_merge($existing, $apiRequest['params']); return civicrm_api($apiRequest['entity'], 'create', $p); }