2

I had an install of CiviCRM which had CiviMail and all email working fine. I was using sendgrid to deliver the email, and ran out of credits. Unsent mail had piled up in the Civi system and I attempted to clear caches and temporarily had the system in debug mode. Now I can not send mail via CiviMail nor via individual emails selected from a search, for example. Both give the same error about missing bundle property on entity of type node. The only email I can send is the test of the SMTP server settings from /civicrm/admin/setting/smtp?reset=1

This problem started while running 4.6.16. I attempted an upgrade to 4.7.12 and get the same error, so that did not fix it.

entire backtrace message with minor edits for privacy:

LOCATION  http://esoduplicate.evanstonsymphony.org/civicrm/contact/search/advanced?_qf_Email_display=true&qfKey=df6b23737309806ea2bf2ae9b9b9cbc1_2533
REFERRER  http://esoduplicate.evanstonsymphony.org/civicrm/contact/search/advanced?_qf_Advanced_display=true&qfKey=df6b23737309806ea2bf2ae9b9b9cbc1_2533
MESSAGE  $backTrace = 
  #0 /path-to-site/sites/all/modules/civicrm/CRM/Core/Error.php(454): CRM_Core_Error::backtrace("backTrace", TRUE) 
  #1 /path-to-site/sites/all/modules/civicrm/CRM/Core/Invoke.php(57): CRM_Core_Error::handleUnhandledException(Object(EntityMalformedException))
  #2 /path-to-site/sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:4)) 
  #3 [internal function](): civicrm_invoke("contact", "search", "advanced") 
  #4 /path-to-site/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:3)) 
  #5 /path-to-site/index.php(21): menu_execute_active_handler() #6 {main}

$Fatal Error Details = array(3) { 
  ["message"]=> string(47) "Missing bundle property on entity of type node." 
  ["code"]=> NULL
  ["exception"]=> object(EntityMalformedException)#269 (7) { 
    ["message":protected]=> string(47) "Missing bundle property on entity of type node." 
    ["string":"Exception":private]=> string(0) "" 
    ["code":protected]=> int(0) 
    ["file":protected]=> string(52) "/path-to-site/includes/common.inc" 
    ["line":protected]=> int(7907) 
    ["trace":"Exception":private]=> array(21) { 
      [0]=> array(4) { 
        ["file"]=> string(69) "/path-to-site/modules/field/field.multilingual.inc" 
        ["line"]=> int(268) 
        ["function"]=> string(18) "entity_extract_ids" 
        ["args"]=> array(2) { 
          [0]=> string(4) "node" 
          [1]=> bool(false) 
        } 
      } 
      [1]=> array(4) {
        ["file"]=> string(59) "/path-to-site/modules/field/field.module" 
        ["line"]=> int(941) 
        ["function"]=> string(14) "field_language" 
        ["args"]=> array(4) { 
          [0]=> string(4) "node" 
          [1]=> bool(false) 
          [2]=> string(4) "body" 
          [3]=> NULL 
        } 
     } 
     [2]=> array(4) { 
       ["file"]=> string(81) "/path-to-site/sites/all/modules/esoCiviMail/esoCiviMail.module" 
       ["line"]=> int(190) 
       ["function"]=> string(15) "field_get_items" 
       ["args"]=> array(3) { 
         [0]=> string(4) "node" 
         [1]=> bool(false) 
         [2]=> string(4) "body" 
       } 
     } 
     [3]=> array(4) { 
       ["file"]=> string(77) "/path-to-site/sites/all/modules/civicrm/CRM/Utils/Hook.php" 
       ["line"]=> int(240) 
       ["function"]=> string(31) "esoCiviMail_civicrm_tokenValues" 
       ["args"]=> array(5) { 
         [0]=> &array(1) { 
           [2]=> array(9) { 
             ["contact_id"]=> string(1) "2" 
             ["sort_name"]=> string(11) "Example, Tim" 
             ["display_name"]=> string(10) "Tim Example" 
             ["do_not_email"]=> string(1) "0" 
             ["preferred_mail_format"]=> string(4) "Both" 
             ["is_deceased"]=> string(1) "0" 
             ["email_id"]=> string(1) "2" 
             ["email"]=> string(19) "tim[at]example.com" 
             ["on_hold"]=> string(1) "0" 
           } 
         } 
         [1]=> array(1) { 
           [0]=> int(2) 
         } 
         [2]=> NULL 
         [3]=> array(0) { } 
         [4]=> NULL 
       } 
     } 
     [4]=> array(6) { 
       ["file"]=> string(88) "/path-to-site/sites/all/modules/civicrm/CRM/Utils/Hook/DrupalBase.php" 
       ["line"]=> int(85) 
       ["function"]=> string(8) "runHooks" 
       ["class"]=> string(14) "CRM_Utils_Hook" 
       ["type"]=> string(2) "->" 
       ["args"]=> array(9) { 
  • 1
    When I do a quick Google search on the error I get the impression its origin is drupal (specially the entity system). Do you have some extra drupal civicrm modules installed? – Kainuk - CiviCooP Nov 3 '16 at 16:57
  • 1
    I figured it out. It was a custom module to supply custom tokens which we had written and interacted with CiviMail. I think a date change trigger made the problems both appear on the same day and made debugging harder. Plus I don't really understand why it impacted all mail, even if it used no part of the module and the non-CiviMail part of the system. I guess the hook impacts all mail: esoCiviMail_civicrm_tokens – TimETown Nov 3 '16 at 22:26
3

This doesn't seem to be a problem with the mail system, as you say it's some custom code which prevented mails being generated or sent.

I see you've identified this - great! And yes, all tokens are generated for each email sent, even if they aren't used - so token generators need to handle situations like this.

To help others - I've reformatted the backtrace so it's more readable, and removed some personal details (possibly your own).

The real problem here was that the entity, as provided to field_get_items(), was being passed as FALSE - perhaps because the module had failed to look up a matching user account?

SO instead of (pseudocode) -

$user = esoCiviMail_get_related_user($contact_id);
$foo = field_get_items('user', $user);
// generate tokens

you'd want to do

if ($user = esoCiviMail_get_related_user($contact_id) {
  $foo = field_get_items('user', $user);
  // generate tokens
}
// else { 
//   ... generate "no-result" default tokens 
// }

Possibly you want the esoCiviMail module to check if a node was correctly found, and if not then return some default (possibly blank) token value to the CiviCRM hook it's implementing.

If the contact really has an email of tim[at]example.com instead of tim@example.com I'd expect this to trigger some issues.

  • Ah, I see the problem was a node lookup not a user lookup - same underlying logic holds. – Chris Burgess Nov 3 '16 at 23:15
1

A custom module triggered this problem.

description =  Define custom tokens CiviMail
dependencies[] = civicrm
files[] = esoCiviMail.module


function esoCiviMail_civicrm_tokenValues() /* */
function esoCiviMail_civicrm_tokens(&$tokens) {
// ...
$nid=$node*1; //node id of next concert promo page //
$input_lines="";
// $node does not resolve--THIS IS BROKEN AFTER CONCERT 1
$node = node_load($nid);
$my_field_items = field_get_items('node', $node, 'body');
  if ($my_field_items) {
    $my_field_first_item = reset($my_field_items);
    $input_lines = $my_field_first_item['value'];
  }
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.