safety measure for cron to publish future post
|Reported by:||hailin||Owned by:||anonymous|
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.