phplist

NOTE:: Before reporting an issue, make sure you are running the latest version, currently 3.3.1


View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0017233phplist applicationMessage Send Processpublic20-06-14 22:5917-07-14 15:20
Reporterduncanc 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
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,'
'.$html["footer"]);

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.
Attached Files

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0054008)
michiel (manager)
22-06-14 10:17


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

(0054009)
duncanc (developer)
22-06-14 12:30

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.
(0054126)
duncanc (developer)
03-07-14 20:46

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.
(0054300)
michiel (manager)
17-07-14 15:20

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


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker