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

Import contribution choking on certain errors, with suggested fix

    Details

      Description

      When Contribution Import receives certain errors it isn't handling them but just proceeding forward, leading to a crash and un-helpful PEAR error message.

      The problem is around line 81 of /civicrm/api/v3/Contribution.php in function civicrm_api3_contribution_create, and adding error handling code similar to this will fix the problem:

      $contribution = CRM_Contribute_BAO_Contribution::create($values, $ids);

      ++ //Needs to check whether $contribution returned an error
      ++ if (isset($contribution->_errors)) return civicrm_api3_create_error($contribution->_errors[0]['message']);

      if(!empty($params['use_default_price_set']) && empty($params['id'] )){
      _civicrm_api3_contribution_createdefaultlineitem($params, $contribution);

      Maybe that should just be something like if (isset($contribution->_errors)) return $contribution; but you guys can sort out that type of thing better than I.

        Attachments

          Activity

            People

            • Assignee:
              pratik.joshi Pratik Joshi
              Reporter:
              bhugh Brent Hugh
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: