WordPress.org

Make WordPress Core

Opened 14 years ago

Closed 12 years ago

Last modified 12 years ago

#5063 closed defect (bug) (duplicate)

Potential type mismatch in post cron hooks

Reported by: tellyworth 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)

#1 @Otto42
14 years ago

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.

#2 @Denis-de-Bernardy
12 years ago

  • Milestone 2.9 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Closing this as a dup. I've bumped into 2 or 3 similiar bugs in the past week. One in particular was related to future posts not working as expected in some odd circumstances.

Note: See TracTickets for help on using tickets.