1

Steps to reproduce:

  • Search -> Find contribution
  • Search for a contribution
  • Choose "Email - send now" as action
  • Choose an email template with a token. In our case we just use the token "{contact.email_greeting}"
  • Send the email

The following error message appears several times for each email:

Warning: array_search() expects parameter 2 to be array, null given in CRM_Contribute_BAO_Contribution::getContributionTokenValues() (line 5769 of \sites\all\modules\civicrm\CRM\Contribute\BAO\Contribution.php).

We use CiviCRM with Drupal 7 and the latest CiviCRM 5.29.1.

For me it seems that the code

    if (strpos($fieldName, 'custom_') === 0 && array_search($fieldName, $messageToken['contribution']) !== FALSE) {
      $result['values'][$id][$fieldName] = CRM_Core_BAO_CustomField::displayValue($result['values'][$id][$fieldName], $fieldName);
    }

should be

    if (isset($messageToken['contribution']) && strpos($fieldName, 'custom_') === 0 && array_search($fieldName, $messageToken['contribution']) !== FALSE) {
      $result['values'][$id][$fieldName] = CRM_Core_BAO_CustomField::displayValue($result['values'][$id][$fieldName], $fieldName);
    }

because by now array_search($fieldName, $messageToken['contribution']) assumes that $messageToken['contribution'] is set which does not seem to be true in every case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.