[wp-hackers] Hooking into wp-cron settings?

Andrew Nacin wp at andrewnacin.com
Mon Dec 13 16:02:47 UTC 2010


On Mon, Dec 13, 2010 at 10:46 AM, Chip Bennett <chip at chipbennett.net> wrote:
>
>  > You can add a filter on http_request_args and modify the timeout there
> > if doing cron. e.g. (completely untested)
> >
> > function my_cron_http_request_args($r) {
> >     if (defined('DOING_CRON') && DOING_CRON) {
> >          $r['timeout'] = 5;
> >     }
> >     return $r;
> > }
> > add_filter('http_request_args', 'my_cron_http_request_args');
>

You're trying to change the timeout for the spawn, not wp-cron, so
DOING_CRON won't be defined.

http_request_args passes a second arg, $url. You'll want to set timeout to 5
when $url = get_option('siteurl') . '/wp-cron.php'.

I wouldn't call that a recommended fix. Five seconds is a long time to wait
for the user who gets caught with that. 0.01 should work under any transport
we support currently (exception, WP 2.9.0, fixed in WP 2.9.1), though I'd
either use the alternate cron, or by firing wp-cron at the system level.

Nacin


More information about the wp-hackers mailing list