[wp-testers] wp_schedule_single_event() acting funny

scribu scribu at gmail.com
Mon Jan 5 20:42:06 GMT 2009


Ok, thanks for the heads up! Although, in the plugin, I wasn't calling it
from the body.

The original problem was that if I set the timestamp to the future, like *
time()+15*, it didn't fire at all.

On Mon, Jan 5, 2009 at 4:47 PM, Otto <otto at ottodestruct.com> wrote:

> If you put your wp_schedule_single_event in the main body like that,
> then you're scheduling a new event on every single page load, because
> the plugin is included on every WordPress page load.
>
> This includes the loads of the cron job itself, which will fire the
> plugin, causing another scheduling to occur, and so on.
>
> Short version: Never, ever, schedule something from the main body of a
> plugin. Stick it in a function, then fire that function only when you
> need to actually schedule the event.
>
>
> On Fri, Jan 2, 2009 at 3:56 PM, scribu <scribu at gmail.com> wrote:
> > Hello, new to this list.
> >
> > I was working on a plugin using wp_cron and I noticed some strange
> > behaviour when using wp_schedule_single_event().
> >
> > I've written this test plugin: http://wordpress.pastebin.ca/1298571
> >
> > If I set it to a time in the past, like
> >
> >  wp_schedule_single_event(time(), CRON_HOOK);
> >
> > it fires twice on every page load.
> >
> > If I set it in the future, say
> >
> >  wp_schedule_single_event(time()+15, CRON_HOOK);
> >
> > it just fires once, even if I clear the hook first.
> >
> > Any ideas?
> >
> > I'm using WP 2.7.1-alpha-10188 on localhost (Ubuntu 8.10 + LAMP).
>

-- 
http://scribu.net


More information about the wp-testers mailing list