A single '<' is added to the beginning of all confirmation emails
adamo - February 10, 2009 - 17:20
| Project: | Simplenews Template |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
This happens in function _simplenews_template_mail_alter_simplenews_node. This function probably shouldn't even be executed for confirmation emails. Here is the code in question:
$content = $message['body']['body'];
// Retrive and filter the header content
$header = _simplenews_template_get_header($tid);
$header = check_markup($header, _simplenews_template_get_header_format($tid), false);
// Retrive and filter the footer content
$footer = _simplenews_template_get_footer($tid);
$footer = check_markup($footer, _simplenews_template_get_footer_format($tid), false);
// Add headers and footer
$content = theme('simplenews_template_content', $newsletter->name, $node->title, $header, $content, $footer);
// Fetch Simplenews Template styling for this newsletter
$style = _simplenews_template_get_css($tid);
$bgcolor = _simplenews_template_get_bgcolor($tid);
// Markup node body with Simplenews Template style
$content = theme('simplenews_template_mail', $newsletter->name, $node->title, $content, $style, $bgcolor);
// Run HTML and CSS through Emogrifier, if available
$content = _simplenews_template_emogrify($content, $css);
$message['body']['body'] = $content;For a confirmation email, $message['body']['body'] doesn't exist. I'm not sure why this results in '<' getting added to the beginning of $message['body'], but that's what's happening.
This fixed the problem for me (but I'm sure there's a better solution):
$content = $message['body']['body'];
if (strlen(trim($content)) > 0) {
// Retrive and filter the header content
$header = _simplenews_template_get_header($tid);
$header = check_markup($header, _simplenews_template_get_header_format($tid), false);
// Retrive and filter the footer content
$footer = _simplenews_template_get_footer($tid);
$footer = check_markup($footer, _simplenews_template_get_footer_format($tid), false);
// Add headers and footer
$content = theme('simplenews_template_content', $newsletter->name, $node->title, $header, $content, $footer);
// Fetch Simplenews Template styling for this newsletter
$style = _simplenews_template_get_css($tid);
$bgcolor = _simplenews_template_get_bgcolor($tid);
// Markup node body with Simplenews Template style
$content = theme('simplenews_template_mail', $newsletter->name, $node->title, $content, $style, $bgcolor);
// Run HTML and CSS through Emogrifier, if available
$content = _simplenews_template_emogrify($content, $css);
$message['body']['body'] = $content;
}
#1
My bad, the above looked like it worked at first, but it doesn't... Referencing $message['body']['body'] when only $message['body'] exists apparently grabs the first character from $message['body']. So $content gets filled with the first character of the message body and then the header/footer/etc are added to that, then $message['body']['body'] = $content; ends up replacing the first character of the message body with the first character of $content which is '<'. This really does fix it:
if (is_array($message['body']['body'])) {
$content = $message['body']['body'];
// Retrive and filter the header content
$header = _simplenews_template_get_header($tid);
$header = check_markup($header, _simplenews_template_get_header_format($tid), false);
// Retrive and filter the footer content
$footer = _simplenews_template_get_footer($tid);
$footer = check_markup($footer, _simplenews_template_get_footer_format($tid), false);
// Add headers and footer
$content = theme('simplenews_template_content', $newsletter->name, $node->title, $header, $content, $footer);
// Fetch Simplenews Template styling for this newsletter
$style = _simplenews_template_get_css($tid);
$bgcolor = _simplenews_template_get_bgcolor($tid);
// Markup node body with Simplenews Template style
$content = theme('simplenews_template_mail', $newsletter->name, $node->title, $content, $style, $bgcolor);
// Run HTML and CSS through Emogrifier, if available
$content = _simplenews_template_emogrify($content, $css);
$message['body']['body'] = $content;
}
#2
Sheesh. Ignore all the other code I posted. The real issue this:
Adding some empty placeholder functions in the "simplenews templating callbacks" section solves the problem:
/**
* Placeholder function for subscribe emails
*/
function _simplenews_template_mail_alter_simplenews_subscribe(&$message) {
// Do nothing
}
/**
* Placeholder function for unsubscribe emails
*/
function _simplenews_template_mail_alter_simplenews_unsubscribe(&$message) {
// Do nothing
}
#3
This does not seem to be a problem anymore (check last dev version)
#4
Automatically closed -- issue fixed for 2 weeks with no activity.