Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Fix return value on deleting financial type #16280

Merged
merged 1 commit into from
Jan 13, 2020

Conversation

seamuslee001
Copy link
Contributor

Overview

The code in the API expects that if a deletion via the del method has been successful it should not return FALSE yet that is what financial Type does

Before

wrong return parameter used

After

correct return is used

ping @mattwire @eileenmcnaughton @colemanw

@civibot
Copy link

civibot bot commented Jan 12, 2020

(Standard links)

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 maybe we should return nothing?

I see

  if (method_exists($bao_name, 'del')) {
    $dao = new $bao_name();
    $dao->id = $params['id'];
    if ($dao->find()) {
      $bao = call_user_func_array([$bao_name, 'del'], $args);
      if ($bao !== FALSE) {
        return civicrm_api3_create_success();
      }

But I also see

    if ($this->_action & CRM_Core_Action::DELETE) {
      $errors = CRM_Financial_BAO_FinancialType::del($this->_id);
      if (!empty($errors)) {
        CRM_Core_Error::statusBounce($errors['error_message'], CRM_Utils_System::url('civicrm/admin/financial/financialType', "reset=1&action=browse"), ts('Cannot Delete'));
      }

Other BAO are inconsistent.... but if we stick with TRUE the above needs fixing

Extend unit test to cover deleting fin type
@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton i have opted to fix the form as i think it makes more sense to stick with returning TRUE as the thing succeeded so lets return TRUE

@eileenmcnaughton
Copy link
Contributor

OK - looks good then

@seamuslee001 seamuslee001 merged commit 121bc7d into civicrm:master Jan 13, 2020
@seamuslee001 seamuslee001 deleted the fintype_delete branch January 13, 2020 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants