#5063 closed defect (bug) (duplicate)
Potential type mismatch in post cron hooks
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
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.
Change History (2)
Note: See
TracTickets for help on using
tickets.
The specific-ness of the args requirement can indeed be somewhat annoying at times.
Suggest making a function that will allow somebody to clear a hook without knowing the args at all. Given only the hook name, remove all scheduled references to it, period. It would help with cleanup functions, such as those when deactivating a plugin.