Closed (duplicate)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 Apr 2009 at 20:23 UTC
Updated:
23 Aug 2009 at 22:47 UTC
Currently in any implementation of hook_mail_alter(), $message['body'] can be either an array or a string, but that is not documented very well. The standard throughout core seems to use an array for e-mail bodies, so why can't we just standardize it? Here are my findings from #331960: Fatal error: [] operator not supported for strings:
Modules can either pass an array or a string as a mail 'body' to drupal_mail(). Watcher.module and comment_subscribe.module use a string instead of an array.
function _watcher_email_notifications_send_message($qmsg) { ... // Body $body = html_entity_decode(strip_tags(filter_xss($qmsg->message)), ENT_QUOTES); ... $params['body'] = $body; ... // Send email $message = drupal_mail('watcher', 'notification', $to, $language, $params, $from, true);Note that the message body doesn't 'officially' become an array until after mail_alter calls are finished (see drupal_mail):
// Invoke hook_mail_alter() to allow all modules to alter the resulting e-mail. drupal_alter('mail', $message); // Concatenate and wrap the e-mail body. $message['body'] = is_array($message['body']) ? drupal_wrap_mail(implode("\n\n", $message['body'])) : drupal_wrap_mail($message['body']);
Comments
Comment #1
dave reidCross-tagging for core issues that need to be fixed for the Mollom.module.
Comment #2
dave reidThis is a duplicate of #455172: drupal_mail() example encourages $message['body'] to be set as a string rather than array. Wish we had our 'search for duplicate issues first' since this was created first. :)
Comment #3
joshmillerCleaning up DrupalWTF list... Since this is a duplicate, removing tag...
Comment #4
dave reid@joshmiller: You know you don't need to remove tags? You can just select 'Open Issues' and it won't show closed/wont'fix/duplicate/etc issues. For those of us subscribed to e-mails we're getting emails when you update all these.