Item8354: Newsletter mode fails if %STARTPUBLISH%/%STOPPUBLISH% used in the topic

pencil
Priority: Urgent
Current State: Closed
Released In: 1.0.9
Target Release: patch
Applies To: Extension
Component: MailerContrib
Branches:
Reported By: Foswiki:Main.MartinRowe
Waiting For:
Last Change By: PaulHarvey
I had an issue with mailnotify -nochanges reporting a missing 'From:' in lib/Foswiki/Net.pm line 419

Tracked it down to %STARTPUBLISH% being used in the topic. If start/stop publish was omitted the newsletter was sent without problems. I think the problem is in lib/Foswiki/Contrib/MailerContrib.pm where the section of the template within the publish markers is extracted. At that point the email header has already been applied, and this is then dropped once the %STARTPUBLISH% is found. I moved the line where the header is added ( $tmpl = "$header$tmpl"; ) to after the publish check and this seems to fix it for both use cases

diff --git a/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm b/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm
index d89731d..54314d3 100644
--- a/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm
+++ b/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm
@@ -489,7 +489,6 @@ sub _sendNewsletterMail {
     my $tmpl = "$body\n$footer";
     $tmpl = Foswiki::Func::expandCommonVariables( $tmpl, $topic, $web );
     $tmpl = Foswiki::Func::renderText( $tmpl, "", $meta );
-    $tmpl = "$header$tmpl";
 
     # REFACTOR OPPORTUNITY: stop factor me into getTWikiRendering()
     # SMELL: this code is identical to PublishContrib!
@@ -512,7 +511,7 @@ sub _sendNewsletterMail {
             $newTmpl .= $s;
         }
     }
-    $tmpl = $newTmpl;
+    $tmpl = $header . $newTmpl;
     $tmpl =~ s/.*?<\/nopublish>//gs;
     $tmpl =~ s/%MAXREV%/$maxrev/g;
     $tmpl =~ s/%CURRREV%/$maxrev/g;
Hacked it a bit -- OlivierRaginel - 30 Nov 2009

-- MartinRowe - 30 Nov 2009

I will elevate this to urgent to get it to my own attention.

-- KennethLavrsen - 30 Nov 2009

After reviewing the code, I think Martin's guess was correct. It doesn't make any sense to put %STARTPUBLISH% or STOP in the template file, and the header always need to be there, and it already has been evaluated. If someone want his header to support the PUBLISH tags, then we might come up with something else, but I really can't figure of any use-case.

-- OlivierRaginel - 30 Nov 2009

Yes, that makes sense.

-- CrawfordCurrie - 04 Dec 2009

Setting to waiting for release.

Thanks to Martin for the fix. Olivier for the improved fix. And Crawford for "throwing the laundry in the washing machine".

I have just put the laundry in the dryer and taken it out and folded it and put it back in the closet. Ie. released the contrib to foswiki.org Extensions.

This is teamwork! smile

-- KennethLavrsen - 04 Dec 2009

ItemTemplate edit

Summary Newsletter mode fails if %STARTPUBLISH%/%STOPPUBLISH% used in the topic
ReportedBy Foswiki:Main.MartinRowe
Codebase 1.0.8
SVN Range
AppliesTo Extension
Component MailerContrib
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:dfcd0ce01bb3 distro:6303c6abcb69
TargetRelease patch
ReleasedIn 1.0.9
Topic revision: r8 - 17 Jan 2010, PaulHarvey
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy