I think I figured out why nodes are indexed in the wrong order.
$next_nid = db_result(db_query("SELECT nid FROM {node} WHERE nid > %d AND status = 1 $cond ORDER BY nid ASC LIMIT 1", $nid));
$prev_nid = db_result(db_query("SELECT nid FROM {node} WHERE nid < %d AND status = 1 $cond ORDER BY nid DESC LIMIT 1", $nid));
When you sort the node you sorted by nid but they need to by sorted by n.created.
Why ?
Because e.g. : Lets say I have a node story published every day. If I publish today a node "Authored on:" last week, this node will have the biggest nid but the n.created of a last week node.
I added a simple sample in the attachment.
I don't know how achieve this. This idea come to me thinking how views sorts nodes.
Comments
Comment #1
idflorin commentedhttp://img25.imageshack.us/img25/1303/clipboard1iw.jpg
Comment #2
bhosmer commentedI think this has been handled with updates since this issue was posted.
Comment #3
thirdender commentedI'm having this issue too in the latest 7.x-2.x-dev. I tried tweaking the logic a bit but wasn't having much luck. This happens if you choose a single node type for indexing and choose index by NID. From memory, node 17 shows node 16 as both the previous and next node. Node 18 shows node 17 as both the prev and next node. Switching the logic from sort by NID to sort by post date fixed the issue for me.
Comment #4
bhosmer commentedSo there is still an issue with sorting by node id but not by post date?
Comment #5
thirdender commentedYes, seems that way. I was clicking through the articles after installing and configuring, and suddenly found myself at the beginning article again sooner than I expected. Checking the database I saw the next and previous nids were the same for pretty much every entry.
Comment #6
bhosmer commentedOkay, thanks for confirming.
I worked through this issue when I was upgrading and updating to include taxonomy support, but was really only testing it and sorting by post date, not node id. Thanks for confirming that this is still happening.