[pmwiki-devel] Register shutdown...

Crisses crisses at kinhost.org
Fri Nov 3 08:28:46 CST 2006


On Nov 2, 2006, at 4:56 PM, The Editor wrote:

> Ok, I've been really working hard at this, but can't seem to get past
> what is probably a simple little problem.
>
> * EZ Mailing list management via zap and pmwiki.  Done.
> * Saves outgoing newsletters as pages in a pmwiki temp queue:  Done.
> * Markup that can be used to trigger sending of newsletter:  Done.
> * Code to Send Email:  Close to done--needs testing.
> * Way to do Sending Email in background?  HELP! HELP! HELP!
>
> Here is part of the code I have right now in the ZAPnews recipe.
> Basically the markup works, BUT I get a blank page for 20 seconds and
> then the page reloads. I want the page to reload first, and then
> ZAPsendnews to operate quietly in the background. Again, I have Apache
> on XP if that makes a difference.
>
> Can someone help me figure out what is wrong:
>
> Markup('zapnews', '<{$var}', '/\(:zapnews:\\)/', ZAPnews());
>
> function ZAPnews() {
> 	register_shutdown_function('ZAPsendnews');
> 	return "Newsletter being processed";
> 	}
>
> function ZAPsendnews() {
> 	ignore_user_abort();
> 	sleep(20);
> 	ZAPsavepage("Test.Sleep1", "Hello World", "");
> 	die();
> 	}
>
> This last function of course will be rewritten to do the actual
> sending once I get the processing to work right.  Thanks so much in
> advance.

Since I don't know what ZAPsavepage() does & requires, I don't know  
if the problem is the register_shutdown_function or not.

I went to the program code I thought I'd used  
register_shutdown_function in to grab a working example for you --  
turns out it had caused problems because UpdatePage was taking far  
too long, so I had turned it off to debug (I was getting a hung  
process on my laptop -- I'm glad I never made it live!  I'd have a  
mad ISP...).  I got everything working smoothly and forgot to  
reinstate it. :P  So everything is working smoothly without  
register_shutdown_function on my program.  I had fixed UpdatePage  
hanging by temporarily resetting:

	$EditFunctions = array( 'ReplaceOnSave','SaveAttributes',  
'PostPage','AutoCreateTargets');

-- in other words I removed a bunch of functions from the queue of  
items that UpdatePage was running when it created a page (most  
noticably the ones that update RecentChanges pages and check for  
NotifyPosts).  Then forgot to make it write the pages AFTER the  
browser refresh.  Page creation happens so much faster now, I didn't  
notice that I'd forgotten to put it in the background again.  The  
downside is that people can add 100s or 1000s of pages using this  
function, and there's no RecentChanges logged.

Crisses




More information about the pmwiki-devel mailing list