get_next_post, get_previous_post do not work for posts posted within same second
|Reported by:||whoismanu||Owned by:||anonymous|
if you have posts that are published shortly one after the other (e.g. through a script or plugin that posts several posts at once) several of them may end up having the same post_date in the wordpress database table. this is due to the fact that mysql datetime seems to only maintain a precision of one second (see also this discussion: http://bugs.mysql.com/bug.php?id=8523).
the problem now is that wordpress functions like get_next_post/get_previous_post (get_adjacent_post resp.) will no longer work correctly if something like this happens as they solely rely on a comparison of the post_date field and they don't treat the case where these timestamps are the same for several posts. the result is that e.g. get_next_post will pick one of the posts having the same timestamp and "jump" over the others, so the user will never see them.
i see two possibilities around this 1.) treat cases with the same post_date by e.g. looking also at the post id (assuming it is always strictly increasing) or probably preferably 2.) make sure that no two posts have the same post_date timestamp by e.g. increasing post_date artificially when publishing the post and if another post already has the same timestamp.
Change History (13)
- Keywords needs-patch added; post_date get_next_post datetime removed
- Milestone changed from 2.8 to Future Release
comment:2 Viper007Bond — 5 years ago
- Component changed from General to Template
- Severity changed from normal to minor
- Milestone changed from Future Release to 2.9
- Priority changed from normal to low