Ticket #5801 (closed defect: fixed)

Opened 5 months ago

Last modified 4 months ago

safety measure for cron to publish future post

Reported by: hailin Assigned to: anonymous
Priority: normal Milestone: 2.5
Component: General Version: 2.5
Severity: normal Keywords:
Cc:

Description

Sometimes future posts were published before they were scheduled.

There could be two possible reasons:

1, time is off on the local web server. When time is off, it will trigger publishing events ahead of time or ahead of time.

2. our publish future post logic is flawed.

We store future posts to be published in cron field in each blog's option table. Theoretically, only post of type "future" can be stored there.

However, we have so many types of posts (including some legacy types), and transitioning among them is not easy to guarantee to be 100% correctly handled.

Debugging some blogs reveals that there is one post of type "draft" that was included in the cron field in the options table. And to make matter worse, when publish event is fired, we just happily publish the post, even when the type is "draft". So this logic is wrong.

One possible fix is not to publish any post NOT of type "future". But I figure that is too strict. For a safe fix, I only add logic to skip publishing "draft" posts.

Attachments

755_future_posts_wporg.diff (1.8 kB) - added by hailin on 02/09/08 00:28:35.
updated patch with ryan's feedback

Change History

02/08/08 21:12:22 changed by ryan

  • milestone changed from 2.6 to 2.5.

wp_publish_post can be used outside of a future post publication context. Requests to publish drafts should not be ignored. Perhaps a better fix would be to hook a publish_future_post() function to the publish_future_post action that does the necessary checks before calling wp_publish_post().

02/08/08 22:46:38 changed by lloydbudd

  • version set to 2.5.

02/09/08 00:28:35 changed by hailin

  • attachment 755_future_posts_wporg.diff added.

updated patch with ryan's feedback

02/09/08 00:30:34 changed by hailin

wp_publish_post so far is not used anywhere else. But I concur that it is best to make this generic, and independent. Revised the code, tested it, and new patch attached.

02/22/08 19:59:13 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [6985]) Make sure post has future status before publishing from cron. Props hailin. fixes #5801