[pmwiki-users] Duplicate email notification

Hans design5 at softflow.co.uk
Fri Feb 8 04:03:06 CST 2008


Friday, February 8, 2008, 6:06:45 AM, Randy wrote:

> Clue 1: Before I switched from commentboxplus to fox, I used to get
> duplicate email notifications from commentboxplus (which I believe has
> some code overlap with fox). This started around the time that I  
> switched from PmWiki 2.1.x to PmWiki 2.2.x, switched from GoDaddy to
> a2Hosting (which uses a later version of PHP), and updated some recipes.

There is not much common code between fox and commentboxplus.
Still, both use the UpdatePage function, which only got available in
the PmWiki 2.2.0 beta series.

Perhaps you could do some more testing with your system regards
commentboxplus: There are actually two versions:

The latest for PmWiki 2.20 beta, which uses UpdatePage:
http://www.pmwiki.org/pmwiki/uploads/Cookbook/commentboxplus2.zip

and a version for PmWiki 2.1 which does not use UpdatePage:
http://www.pmwiki.org/pmwiki/uploads/Cookbook/commentboxplus.zip

Please try out both (install one at a time) and see if there is a
difference in email notifications for you.

> Clue 2: I switched from commentboxplus to fox in part to eliminate the
> duplicates. It did seem to eliminate most. But I still got duplicates
> when deleting lines via a foxdelete link. Now, with fox's latest  
> version, the duplication is occurring consistently, even for adding
> comments.

(warning: this gets quite technical!)
In this very latest fox.php version (2008-02-07) I changed the
EditFunctions array. Previously Fox used its own array of a few
edit functions, which UpdatePage processed. Now it uses the default
array of functions, with a few exceptions (some specific edit
functions are excluded, because they are not necessary to be called in
the fox processing). So it may be that now an edit function is
processed, which previously was not.

In particular the notify.php script adds an edit function called
PostNotify. PostNotify will act on successful posting and registers
the NotifyUpdate function (which does all the work and mailing)
with register_shutdown_function, so NotifyUpdate will be called after
pmwiki is finished with everything else.

notify.php has also another function to do the same registering of
NotifyUpdate called NotifyCheck, which checks the NotifyFile if any
mailing is pending.

I suspect something goes wrong there for you, and NotifyUpdate is
twice registered, and twice executed, resulting in double emails.
Why I do not know. But notify.php has no mechanism to prevent the
NotifyUpdate function from being twice registered for execution.
Maybe there is some sense in it, but maybe this should not happen.

To stop notify.php executing NotifyUpdate twice you could try this:
In notify.php change right at the bottom

   return true;

to

   exit;

(leave the closing } on the next line though!)

then test your system for email notifications.

The 'exit' will prevent any other function which is registered with
register_shutdown_function to be called, so will prevent another
NotifyUpdate to be called. So this may not be legitimate behaviour,
as other functions may legitimately be registered for execution.
Programmatically it would be better to prevent in notify.php any
double call to register_shutdown_function('NotifyUpdate' ....).
That would require a more substantial code change.

Perhaps Pm or some other php  programmer can illuminate us:

1. Is it necessary that
      register_shutdown_function('NotifyUpdate' ....)
   can be called more than once?

2. What could possible cause more than one call to
      register_shutdown_function('NotifyUpdate' ....)


  ~Hans




More information about the pmwiki-users mailing list