Unfortunately, #3004236: Send by email not working creates a regression. You can no longer send emails from a rule, and you get the following warning:

Warning: array_key_exists() expects parameter 2 to be array, null given in print_mail_form_submit()

This happens when a rule sends an email because the fake $form_state is setup upon in $form_state['values'] rather than $form_state['input']. The changed in the related issue moves the test from values to input, which is not defined when submitting via a rule.

I suggest a more faithful fake $form_state be created:

function print_mail_action_submit($from, $from_name, $to, $subject, $message, $node) {
module_load_include('inc', 'print_mail', 'print_mail');

$form_state['values'] = array(
'path' => 'node/' . $node->nid,
'query' => NULL,
'cid' => NULL,
'title' => $node->title,
'fld_from_addr' => $from,
'fld_from_name' => $from_name,
'txt_to' => array('addrs' => $to),
'fld_subject' => $subject,
'txt_message' => $message,
'chk_teaser' => FALSE,
);
$form_state['input'] = $form_state['values']; // <------ Add this

print_mail_form_submit(NULL, $form_state);
}

I have tested this and it works (both sends the email and avoids the PHP warning).

Comments

DanChadwick created an issue. See original summary.

DanChadwick’s picture

Title: Email rules integration broken by 2.2, PHP Warning array_key_exists. » Email rules integration broken by 7.x-2.2, PHP Warning array_key_exists.
jcnventura’s picture

Status: Active » Needs review

  • jcnventura committed 2137153 on 7.x-2.x
    Issue #3025620 by DanChadwick, jcnventura: Email rules integration...
jcnventura’s picture

Status: Needs review » Fixed

Thanks for the fix. Even if it was not a patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.