Force executing email queue

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
EAM
Registered User
Posts: 93
Joined: Mon Nov 24, 2008 12:45 pm

Force executing email queue

Post by EAM »

I'm manually entering posts which then get put in the queue. I would like to force the queue to execute rather than wait the required interval. I also noticed that even if the interval passes, the emails don't get sent unless someone actually logs in the forum (or maybe some other activity but I only noticed the login event). How can I force the executing and will the next time it executes be affected by my action? Thanks
Drummer
Registered User
Posts: 199
Joined: Wed Jul 21, 2010 11:49 am

Re: Force executing email queue

Post by Drummer »

phpbb uses a little trick to build the cron functionality: it includes the cron.php file as an image source at the footer of the pages. So when a page is being loaded it automatically checks if there is a cron task to be done and do it. When there is no activity (clicking), there is no cron processing.
If you want to process it right way, you have to create an instance of queue and call queue::process() in includes/functions_posting.php - submit_post() and includes/mcp/mcp_queue.php - approve_post().
User avatar
EAM
Registered User
Posts: 93
Joined: Mon Nov 24, 2008 12:45 pm

Re: Force executing email queue

Post by EAM »

Will this process it right away regardless of the time interval passage? Thanks
Drummer
Registered User
Posts: 199
Joined: Wed Jul 21, 2010 11:49 am

Re: Force executing email queue

Post by Drummer »

I guess so.
cron.php checks if (time() - $config['queue_interval'] <= $config['last_queue_run']) and only call queue::process() if not. queue::process() only sets $config['last_queue_run'] to "now".
User avatar
EAM
Registered User
Posts: 93
Joined: Mon Nov 24, 2008 12:45 pm

Re: Force executing email queue

Post by EAM »

Great! I'll give it a try. Thanks
User avatar
Martin Truckenbrodt
Registered User
Posts: 3045
Joined: Sun Mar 23, 2003 6:22 pm
Location: Franconia
Name: Martin Truckenbrodt
Contact:

Re: Force executing email queue

Post by Martin Truckenbrodt »

Hello,
an example from Advanced Double Activation Pack used for auto prune users:

Code: Select all

		<open src="index.php">
			<edit>
				<find><![CDATA[$user->setup('viewforum');
]]></find>
				<action type="after-add"><![CDATA[// Do the user prune thang - cron type job ...
if ($config['user_prune_period'] && intval($config['user_prune_next']) < time())
{
	$template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=prune_user') . '" alt="cron" width="1" height="1" />');

	set_config('user_prune_next', time() + intval($config['user_prune_period']) * 86400);
	$run_cron = false;
}
else
{
	$run_cron = true;
}
]]></action>
			</edit>
			<edit>
				<find><![CDATA[page_footer();]]></find>
				<action type="replace-with"><![CDATA[page_footer($run_cron);]]></action>
			</edit>
		</open>
This action only is done not mor than once per day.
Perhaps a little help?
Bye Martin
Free tutorial: Installing MODs in phpBB 3.0
Advanced Block MOD - Prevent spam on your phpBB 3.0 board with Stop Forum Spam, BotScout, Akismet, Project Honey Pot and several IP-RBL and Domain-RBL DNS blacklists!
My MODs
Use the official phpBB Ideas to vote missing core features!!!
Drummer
Registered User
Posts: 199
Joined: Wed Jul 21, 2010 11:49 am

Re: Force executing email queue

Post by Drummer »

Martin Truckenbrodt wrote:Hello,
an example from Advanced Double Activation Pack used for auto prune users:

Code: Select all

		<open src="index.php">
			<edit>
				<find><![CDATA[$user->setup('viewforum');
]]></find>
				<action type="after-add"><![CDATA[// Do the user prune thang - cron type job ...
if ($config['user_prune_period'] && intval($config['user_prune_next']) < time())
{
	$template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=prune_user') . '" alt="cron" width="1" height="1" />');

	set_config('user_prune_next', time() + intval($config['user_prune_period']) * 86400);
	$run_cron = false;
}
else
{
	$run_cron = true;
}
]]></action>
			</edit>
			<edit>
				<find><![CDATA[page_footer();]]></find>
				<action type="replace-with"><![CDATA[page_footer($run_cron);]]></action>
			</edit>
		</open>
This action only is done not mor than once per day.
Perhaps a little help?
Bye Martin
Did you ask for help?
User avatar
Martin Truckenbrodt
Registered User
Posts: 3045
Joined: Sun Mar 23, 2003 6:22 pm
Location: Franconia
Name: Martin Truckenbrodt
Contact:

Re: Force executing email queue

Post by Martin Truckenbrodt »

Hi Drummer,
no. My code is running.

Bye Martin
Free tutorial: Installing MODs in phpBB 3.0
Advanced Block MOD - Prevent spam on your phpBB 3.0 board with Stop Forum Spam, BotScout, Akismet, Project Honey Pot and several IP-RBL and Domain-RBL DNS blacklists!
My MODs
Use the official phpBB Ideas to vote missing core features!!!
Locked

Return to “[3.0.x] MOD Writers Discussion”