Opened 15 years ago
Closed 14 years ago
#12650 closed defect (bug) (duplicate)
Multiple posts with same date do not link to each other with next_post_link and previous_post_link.
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.9.2 |
Component: | General | Keywords: | needs-patch |
Focuses: | Cc: |
Description
Example:
You have 4 posts with ID of 1, 2, 3, and 4.
post_dates are as follows:
1) 2010-03-19 08:42:01
2) 2010-03-19 08:42:02
3) 2010-03-19 08:42:02
4) 2010-03-19 08:42:04
Post 2 will link to post 1 with previous_post_link.
Post 2 will link to post 4 with next_post_link. - should be 3
Post 3 will link to post 1 with previous_post_link.
Post 3 will link to post 4 with next_post_link. - should be 2
This is due to not expecting two posts to have the same exact date (in a normal install, they probably wouldn't... but with multiple users, this becomes an issue). Currently, the code selects datetimes less than or greater than current time (does not include current time). It also only orders by post_date.
To fix this issue, you must change > and < to >= and <= to include the current time as well (all posts that were posted during that second). Then, to avoid linking to the same post, order by ID and add a WHERE clause to catch the post with an ID > or < (does not include current post... remains consistent in grabbing the prev/next post) than the current ID.
Fix attached.
Refer to lines 955, 956, 960, and 961 in attached file to see the fix.
Set priority to high because this is very important to sites with multiple users or to sites that import data from other systems and the datetime is flawed -- For example, the database I imported into Wordpress was imported into Drupal last year by another developer, but he did not transfer the timestamps to drupal. This caused our data to have 4+ rows per timestamp (imported all at once).
Attachments (2)
Change History (10)
#3
@
15 years ago
- Keywords needs-patch added; next_post_link previous_post_link has-patch removed
- Milestone changed from 2.9.3 to 3.0
- Priority changed from high to normal
Needs an actual patch. This is just a PHP file.
has-patch