View Issue Details

IDProjectCategoryView StatusLast Update
0017233phpList 3 applicationCampaign Send Processpublic17-07-14 15:20
Reporterduncanc Assigned To 
Status resolvedResolutionfixed 
Product Version3.0.6 
Target Version3.0.7Fixed in Version3.0.7 
Summary0017233: Footer is added twice when used as a placeholder
DescriptionUsing the [FOOTER] placeholder explicitly to position the footer in a message leads to it being included twice.

When a message is being built, in the function precacheMessage() in admin/sendemaillib.php, a whole set of message fields are used as placeholders. See lines 1478 onwards

  foreach($message as $key => $val) {
    if (!is_array($val)) {
      $cached[$messageid]['content'] = str_ireplace("[$key]",$val,$cached[$messageid]['content']);
      $cached[$messageid]["textcontent"] = str_ireplace("[$key]",$val,$cached[$messageid]["textcontent"]);
      $cached[$messageid]["textfooter"] = str_ireplace("[$key]",$val,$cached[$messageid]['textfooter']);
      $cached[$messageid]["htmlfooter"] = str_ireplace("[$key]",$val,$cached[$messageid]['htmlfooter']);

Most of these fields are not documented as placeholders and probably should not be treated as placeholders, such as 'requeueinterval' or obscurely 'workaround_fck_bug', but some are actually genuine placeholders that need to be replaced for each subscriber, not just for the message.
An example of that is the footer field. The [FOOTER] placeholder is replaced in this function, but the per-subscriber processing also looks for a [FOOTER] placeholder, see lines 306 onwards

  if (strpos($htmlmessage, "[FOOTER]") !== false)
    $htmlmessage = str_ireplace("[FOOTER]",$html["footer"],$htmlmessage);
  elseif ($html["footer"])
    $htmlmessage = addHTMLFooter($htmlmessage,'

This causes the footer value to be used twice, once by precacheMessage() and then again by the elseif part of this processing (as by that time the placeholder does not exist).

I suggest that precacheMessage() should be restricted to replace only those message fields that are documented as placeholders and are applicable to the message and not the subscriber.
TagsNo tags attached.



22-06-14 10:17

administrator   ~0054008

but once it's been replaced the first time, the placeholder has gone, so the second one won't apply?


22-06-14 12:30

updater   ~0054009

It is the 'elseif' that applies, because $html['footer'] is set. This puts the footer at the end of the message in addition to where the [FOOTER] placeholder occured.


03-07-14 20:46

updater   ~0054126

After looking at the code I cannot see the reason for the code at line 1478 of sendemaillib.php in using all messagedata fields as potential placeholders.

There seems to be only a small number of fields that should be used as placeholder, such as message id, subject.


17-07-14 15:20

administrator   ~0054300

yes, the foreach seems to replace too many things. I've changed it to only use subject and id.