[wp-hackers] overriding the built-in cache

Scott Merrill skippy at skippy.net
Thu Jan 5 03:45:02 GMT 2006


I am having some trouble with my wp-cron plugin, and I'm pretty sure
it's the new caching mechanism that's causing it.

WP-Cron stores three values in the options table:
   wp_cron_15_lastrun
   wp_cron_hourly_lastrun
   wp_cron_daily_lastrun
Each of these is a timestamp of when the corresponding function last
ran.  The wp_cron_init() function, which executes at plugins_loaded,
loads these values and compares them to the current time.  If the
current time is sufficiently past the last run time, a shutdown action
is registered.

For WordPress 1.5, this mostly worked.

With WordPress 2.0, though, I'm seeing much weirdness.  For example, I
added the following, as a test mechanism, on my test site:
add_action('wp_cron_hourly', 'sdm_test');
function sdm_test() {
   $cron = get_option('wp_cron_hourly_lastrun');
   mail('skippy at skippy.net', 'cron hourly', "cron: $cron\ntime: " .
time() );
}

_Every_ visit to my test site sends me an email, even if it is not yet
time to run the hourly action.

I then modified wp_cron_init() to call wp_cache_flush() if it is time to
run a cron job.  That failed, and I still get the test email with every
page view.

Even uncommenting DISABLE_CACHE in wp-settings.php does not work: I
still get an email with every page view, even though the current time is
less than wp_cron_hourly_lastrun + 3600.

I've skimmed wp-includes/cache.php, but I confess that I don't quite get
how it works yet.

How can a plugin bypass the cache on a programmatic basis?  Is it even
possible?

-- 
skippy at skippy.net | http://skippy.net/

gpg --keyserver pgp.mit.edu --recv-keys 9CFA4B35
506C F8BB 17AE 8A05 0B49  3544 476A 7DEC 9CFA 4B35


More information about the wp-hackers mailing list