Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-9356

Value overwritten with null on update API call when field has unique name

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Critical
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.1.0
    • Fix Version/s: 4.1.0
    • Component/s: CiviCRM API
    • Labels:
      None

      Description

      When an API call is made to an entity which has a field with a unique name, but that field is not included in the API parameters, array, _civicrm_api3_swap_out_aliases will create that parameter with a null value. On update calls, the preexisting value will be overwritten with null. The unit test api_v3_PledgePaymentTest::testUpdatePledgePayment fails because of that.

      This is the offending line (_civicrm_api3_swap_out_aliases, api/v3/utils.php line 1037):

      }elseif(empty($apiRequest['params'][$field]) && CRM_Utils_Array::value('uniqueName', $values) && $field != $values['uniqueName'])

      { $apiRequest['params'][$field] = CRM_Utils_Array::value($values['uniqueName'],$apiRequest['params']); }

      The attached patch adds an array_key_exists check. It should probably done for the other two if branches too, but I wasn't sure about that.

        Attachments

          Activity

            People

            • Assignee:
              eileen Eileen McNaughton
              Reporter:
              tgr Tisza Gergő
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: