[wp-trac] [WordPress Trac] #8107: get_next_post, get_previous_post do not work for posts posted within same second

WordPress Trac wp-trac at lists.automattic.com
Sat Nov 8 12:34:23 GMT 2008


#8107: get_next_post, get_previous_post do not work for posts posted within same
second
-----------------------+----------------------------------------------------
 Reporter:  whoismanu  |       Owner:  anonymous                       
     Type:  defect     |      Status:  new                             
 Priority:  normal     |   Milestone:  2.8                             
Component:  General    |     Version:  2.7                             
 Severity:  normal     |    Keywords:  post_date get_next_post datetime
-----------------------+----------------------------------------------------
 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.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8107>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list