Potential type mismatch in post cron hooks
|Reported by:||tellyworth||Owned by:||anonymous|
The wp cron functions are very picky about argument types. For example, if I do this:
$post_id = '123'; wp_schedule_single_event($time, 'foo', array($post_id)); wp_clear_scheduled_hook('foo', (int)$post_id);
..the hook won't get cleared as expected, because the type of the post_id argument doesn't match (string vs int) even though its value is the same. That's an easy mistake to make: in wp-includes/post.php, post ID's are passed around that are variously strings or ints at different places in the code. I'm not aware of any code that currently breaks, but it's a bug waiting to happen.
To add to the confusion, Wordpress and Wordpress-mu store cron hooks with different post ID types: Wordpress uses a string, Wordpress-mu uses an int.
I'm not sure what the solution is, but it's probably worth noting somewhere.