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 thisprint_mail_form_submit(NULL, $form_state);
}
I have tested this and it works (both sends the email and avoids the PHP warning).
Comments
Comment #2
DanChadwick CreditAttribution: DanChadwick commentedComment #3
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedComment #5
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedThanks for the fix. Even if it was not a patch.