Opened 17 years ago
Closed 16 years ago
#5364 closed defect (bug) (fixed)
Cron not updated correctly when deleting a future post
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.8 | Priority: | low |
Severity: | minor | Version: | 2.3.1 |
Component: | Optimization | Keywords: | has-patch commit |
Focuses: | 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
Attachments (1)
Change History (14)
#3
@
17 years ago
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.
#5
@
16 years ago
- Component changed from General to Optimization
- Keywords needs-patch added; cron delete post wp_delete_post removed
wontfix? or optimization?
#6
@
16 years ago
- Keywords has-patch commit added; needs-patch removed
- Milestone changed from 2.9 to 2.8
#7
@
16 years ago
While this patch looks fine, it doesn't pass the unit test :-( the cron array still has the scheduled post in it afterwards.
#10
@
16 years ago
so, if #8808 gets applied, and we use array( (string)$post_id ) instead, it should work.
I've confirmed this in a unit test:
See test_delete_future_post_cron() in http://svn.automattic.com/wordpress-tests/wp-testcase/test_includes_post.php.