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

hook_civicrm_tokenValues not called for new email activity with no contact.* tokens

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.1.1
    • Fix Version/s: 4.3.0
    • Component/s: Core CiviCRM
    • Labels:

      Description

      I've been trying to develop custom hook tokens in Drupal 6/CiviCRM 4.1.1 following the example code and the blog the documentation links to at http://wiki.civicrm.org/confluence/display/CRMDOC41/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmtokenValues

      Was pulling my hair out because my hook_civicrm_tokenValues method wasn't getting called on submit of a new email activity. It get's called during setup of the form, but the $tokens param is not populated (as you would expect).

      I eventually got a debugger working and eventually stumbled across CRM/Activity/BAO/Activity.php line 1310 where it calls CRM_Utils_Token::getTokenDetails()

      The problem was that I was testing a message that only contained my own custom tokens and no contact.* tokens. And there is a check to see if $returnProperties is populated before it makes the call to getTokenDetails(), which it is not.

      The fix will be to remove the "if ( !empty( $returnProperties ) )" and document the fact that any hook methods should check to see that their tokens are actually being used in $tokens before doing any expensive processing.

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              mrp40 Mark Presling
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: