Ticket #5364 (new defect (bug))

Opened 1 year ago

Last modified 1 year ago

Cron not updated correctly when deleting a future post

Reported by: develish Assigned to: anonymous
Priority: low Milestone: 2.9
Component: General Version: 2.3.1
Severity: minor Keywords: cron delete post wp_delete_post
Cc:

Description

Hi,

my name is Mariano and this is my first bug report so please bear with me :D

When I delete a future post using wp_delete_post($post->ID) it does not update the cron correctly.

I use this code to actually manually delete and unschedule the future posts

$posts = $wpdb->get_results( "SELECT ID FROM $wpdb->posts where post_status = 'future';" );
foreach ($posts as $post)
  {
    wp_clear_scheduled_hook( 'publish_future_post', $post->ID );
    wp_delete_post($post->ID)<
  }

Maybe a check if the post is of post_status future and then unscheduling it in the post deletion process would fix it.

I was not able to find the unschedule in post.php -> wp_delete_post

Thanks for consideration

Mariano

Change History

11/17/07 19:57:28 changed by tellyworth

I've confirmed this in a unit test:

There was 1 failure:

1) test_delete_future_post_cron(WPTestIncludesPost)
Failed asserting that <integer:1195415622> is false.
/home/zem/projects/wordpress/wordpress-tests/wp-testcase/test_includes_post.php:146
/home/zem/projects/wordpress/wordpress-tests/wp-testlib/base.php:348
/home/zem/projects/wordpress/wordpress-tests/wp-test.php:92

See test_delete_future_post_cron() in http://svn.automattic.com/wordpress-tests/wp-testcase/test_includes_post.php.

11/19/07 20:29:36 changed by lloydbudd

  • milestone changed from 2.5 to 2.4.

02/08/08 16:06:09 changed by hailin

After we delete a post, the post ID becomes invalid. Therefore, even the entry was still in cron, when cron fires up, it tries to retrieve an invalid post, it will return right away. logic is in wp_publish_post:

$post = get_post($post_id);

if ( empty($post) )

return;

So while a fix is good, I don't think there is real harm.

02/08/08 17:08:29 changed by lloydbudd

  • milestone changed from 2.5 to 2.6.