If I create a node and leave it unpublished, the node before it will have a next link to the new node. I must re-index (and run cron) to correct it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

trothwell’s picture

confirmed

trothwell’s picture

I'd just like to comment down that a fix i've been trying to work on actually defeats the purpose of this module so i'm not going to bother continuing to attempt a patch. Slim and fast queries is what the goal was.

I attempted to add a while loop with an inner join going through each entry until it finds the appropriate one. It just doesn't work entirely well. The only other thing i can think off is to add a rebuild on every cron run and have the cron run on a regular basis.

For anyone who is interested here is my first attempt (should be replicated to the prev function as well):

<?php
function prev_next_nid_next($nid) {
  $search = db_result(db_query("SELECT next_nid FROM {prev_next_node} p INNER JOIN {node} n ON p.next_nid = n.nid WHERE p.nid = %d AND n.status <> 0", $nid));
  while ($search == FALSE) {
	$search = db_result(db_query("SELECT next_nid FROM {prev_next_node} p INNER JOIN {node} n ON p.next_nid = n.nid WHERE p.nid = %d AND n.status <> 0", $nid++));
  }
  return $search;
}
?>
tribsel’s picture

this is pretty serious, if you unpublish node, you break prev/next navigation, in my case. Because anonymous user does not have rights to view unpublished nodes, he gets redirected to login/register screen. One unpublished node makes this whole api useless.

askibinski’s picture

My first thought is this could be solved by adding this functionality.

1. skip indexing unpublished nodes in the first place

when a node is unpublished:
2. remove a node from the prev_next table
3. replace his siblings with the new reference

tricky part might be when an old unpublished node is published:
4. find out where he belongs and basically undo steps 2 and 3.

But I guess there might be already a mechanism for #4.

aasarava’s picture

Status: Active » Needs review
FileSize
703 bytes

I put together this simple patch that seems to work in my testing.

dagmar’s picture

FileSize
604 bytes

The patch works fine. Updated respecting coding standards and using git.

energee’s picture

For Drupal 7 Branch

idflorin’s picture

Issue tags: +For drupal 7

Thanks #7. It works for 7.x version.

gkom’s picture

I confirm that patch #7 works in 7.x. Thank you very much!

energee’s picture

You're welcome!

bhosmer’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

Is this still an issue in the latest 6.x? If it is, feel free to reopen, although support for Drupal 6 is nearing an end.

garbo’s picture

This still seems to be an issue for prev_next 7.2.x

EDIT: sorry, I was actually using prev_next 7.x.1

garbo’s picture

I just tested 7.2.x and I can confirm that this problem still presists in prev_next 7.2.x

garbo’s picture

The patch from #7 seems to do the trick.

bhosmer’s picture

@garbo:

Thanks for updating this issue. Could you perhaps roll the patch against 7.x-2.x and post it?