CRM-20030 civicrm_api3 does not surface errors in chained API requests

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.7.15
    • Fix Version/s: None
    • Component/s: CiviCRM API
    • Labels:
      None
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      Developer Doc
    • Funding Source:
      Needs Funding
    • Verified?:
      No

      Description

      The civicrm_api3() function which detects error conditions in the response object and converts them to exceptions, does not check the results of chained API requests, which may have nested errors preventing the parent request from completing.

      Example response object wherein only a chained child request contains an error and is not detected and thrown by the civicrm_api3() wrapper:

      {{
      Array
      (
      [is_error] => 0
      [version] => 3
      [count] => 1
      [id] => 35107
      [values] => Array
      (
      [0] => Array
      (
      [id] => 35107
      [contact_type] => Individual
      [contact_sub_type] =>
      ... abbreviated for readability ...

      [api.address.replace] => Array
      (
      [error_code] => 2000
      [entity] => Address
      [action] => create
      [is_error] => 1
      [error_message] => Input variable `params` is not an array
      )

      }}

        Attachments

          Activity

          [CRM-20030] civicrm_api3 does not surface errors in chained API requests
          Benjamin Bradley added a comment -

          Here's a very basic brute-force fix that scans the result object for errors in chained API calls.

          Benjamin Bradley added a comment -

          Update: checks for 'values' key in array to avoid Invalid argument warning.

            People

            • Assignee:
              Unassigned
              Reporter:
              Benjamin Bradley

              Dates

              • Created:
                Updated: