Item1847: mailnotify doesn't expand BASEWEB properly

Priority: Normal
Current State: Closed
Released In: 1.0.7, 1.1.0
Target Release: patch
Applies To: Extension
Component: MailerContrib
Reported By: PaulHarvey
Waiting For: OlivierRaginel
Last Change By: KennethLavrsen


On a fresh install of Foswiki 1.0.6,

Running (on Debian Lenny):
cd /var/www/foswiki/bin
sudo -u www-data ../tools/mailnotify -news Sandbox

Where in Sandbox.WebNotify I have:
   * MyUserName: WebHome!

And in Sandbox.WebHome I have:

Which in the E-mail I receive expands as:

... where I expect BASEWEB to be Sandbox instead.


The problem seems to be a shared $twiki instantiation on line 74 of (no parameters so session context defaults to %MAINWEB%). Webs are then processed in the loop down at line 89, all with the same $twiki instantiation, so %BASEWEB% expands as %MAINWEB% .

-- PaulHarvey - 23 Jul 2009

This is a problem that bites PublishPlugin as well. I just checked in a fix on trunk that makes sure it's fixed for future Foswiki versions, and Olivier is working on a fix for the existing code, based on what I did in the PublishPlugin.

-- CrawfordCurrie - 23 Jul 2009

I've coded a unit test for this, and it seems the temporary fix you did for PublishPlugin doesn't fix it. I still have an issue with BASETOPIC being MailNotify, but your fix makes my unit test pass smile

-- OlivierRaginel - 23 Jul 2009

I've attached a diff to that ships with 1.0.6 which fixes this problem for me. However, I'm not a brilliant Perl coder and I haven't had time to thoroughly understand the things I'm touching here. In particular I'm dubious as to how command_line context key value is actually used anywhere.

At first glance it seems it would be useful if was modified to check if command_line=1 and set up webName and topicName (if true) via the %initialContext hash instead of bothering to derive the proper web/topic context from the CGI query object.

-- PaulHarvey - 24 Jul 2009

That's really not what the initial context hash is for. There's a much simpler solution, which Olivier has coded.

-- CrawfordCurrie - 24 Jul 2009

The only issue I have left with my code is that it doesn't seem to expose any problem on the release branch. Only on trunk, and you fixed it.

I'll try to test it again manually (odd, because my unit test works well on trunk) to see...

-- OlivierRaginel - 24 Jul 2009

Ok, it seems the unit tests are broken on the release branch, and I can't really seem to fix that. As the release branch will anyway be dumped "soon", I don't want to invest too much time in this.

PaulHarvey, please wait for 1.1 to be released and it should fix your issue, so you shouldn't have to re-apply your patch (which is OK for you, it might not be OK for people with loads of webs).

-- OlivierRaginel - 27 Jul 2009

ItemTemplate edit

Summary mailnotify doesn't expand BASEWEB properly
ReportedBy PaulHarvey
Codebase 1.0.6
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component MailerContrib
Priority Normal
CurrentState Closed
WaitingFor OlivierRaginel
Checkins distro:2b624dcde3e3 PublishPlugin:5085f0a445d1 PublishPlugin:e89302057030 distro:97fe19ea32c8 distro:b95df53eea05
TargetRelease patch
ReleasedIn 1.0.7, 1.1.0
I Attachment Action Size Date Who Comment manage 1 K 24 Jul 2009 - 05:02 PaulHarvey This patch fixes the issue for me; needs review.
Topic revision: r13 - 20 Sep 2009, KennethLavrsen
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