View Issue Details

IDProjectCategoryView StatusLast Update
2349Composrnewsletterpublic2021-05-07 20:10
ReporterChris Graham Assigned ToChris Graham  
PrioritynormalSeverityfeature 
Status resolvedResolutionfixed 
Summary2349: Implement proper Tempcode binding
DescriptionCurrently the Tempcode is bound into newsletter instances via a hack:

    foreach ($vars as $var => $sub) {
        $message = str_replace('{' . $var . '}', is_object($sub) ? $sub->evaluate() : $sub, $message);
        $message = str_replace('{' . $var . '*}', escape_html(is_object($sub) ? $sub->evaluate() : $sub), $message);
    }

It works, but it is sloppy. If other escapers are used it will fail, but generally it is just inelegant and comes from a much earlier time where the Tempcode engine could not do late binding.

We can do something like...

$message->singular_bind($var, $sub);

(not directly, as $message is a string currently, as we have already flattened it -- so the code needs wider restructuring to accommodate the change)
TagsRisk: General incompatibility
Attach Tags
Time estimation (hours)2
Sponsorship open

Sponsor

Date Added Member Amount Sponsored

Activities

Chris Graham

2016-03-28 03:43

administrator   ~3505

Ah, I can see actually currently the Tempcode parameters are lower case, which may be a reason for the hack. E.g. {member_id}. They will need to be moved over to upper case, which is a compat break.

Chris Graham

2016-04-05 00:34

administrator   ~3528

A related issue is the horrid need for escaping in the default newsletter wrapper...

\{+START,IF_NON_EMPTY,{unsub_url}\}
-------------------------

[font size="0.8"]\{$?,\{$IS_EMPTY,\{member_id\}\},\{!NEWSLETTER_UNSUBSCRIBE_NEWSLETTER,\{unsub_url\}\},\{!NEWSLETTER_UNSUBSCRIBE_MEMBER,\{unsub_url\}\}\}[/font]
\{+END\}



Hopefully our implementation of binding will be Comcode-safe. Comcode will recognise the use of parameters and include these as unbound within generated Tempcode -- allowing binding later.

This likely will require some deep changes in Comcode.

Chris Graham

2021-05-07 20:10

administrator   ~7088

Implemented.
The processing flow has been completely refactored, it's a lot cleaner now.
My last note about Comcode doesn't apply with the new processing flow - Comcode applies last, after a separate Tempcode parse and bind.

Issue History

Date Modified Username Field Change
2016-03-28 03:41 Chris Graham New Issue
2016-03-28 03:42 Chris Graham Description Updated
2016-03-28 03:43 Chris Graham Note Added: 0003505
2016-03-28 03:44 Chris Graham Tag Attached: General incompatibility
2016-04-05 00:34 Chris Graham Note Added: 0003528
2016-06-08 00:15 Chris Graham Tag Renamed General incompatibility => Risk: General incompatibility
2021-05-07 20:10 Chris Graham Assigned To => Chris Graham
2021-05-07 20:10 Chris Graham Status Not Assigned => Resolved
2021-05-07 20:10 Chris Graham Resolution open => fixed
2021-05-07 20:10 Chris Graham Note Added: 0007088