Opened 17 years ago
Closed 17 years ago
#5801 closed defect (bug) (fixed)
safety measure for cron to publish future post
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.5 |
Component: | General | Keywords: | |
Focuses: | 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.
- 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.
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().