How to reproduce the bug:

  1. Make sure that the content type you are editing has both New revisions in moderation and Create new revision checked.
  2. Create a new node of the content type above with a user that does not have the administer nodes permission.
  3. With the same user, make two edits of the same node. This will create two new pending revisions.
  4. Go to the Pending revisions page with a user with administer nodes permission (i.e. a Publisher). Only one of the revisions of your node will appear, and it is the oldest one pending revision. This causes Publishers to review the wrong revision.

The cause of the bug:
The SQL query in function revision_moderation_get_all_pending_revisions($limit) fetches pending revisions of a node instead of just the latest revision. When fetching the result, each revision will be added to the $revisions array with $revision->nid as key. Since the revisions are sorted DESC, it will overwrite existing revisions in the array until it has added the oldest revision.

Overwrites newer revisions with older ones when fetching the result:

  while ($revision = db_fetch_object($result)) {
    $revisions[$revision->nid] = $revision;
  }

Incorrect query, fetches all pending revisions of a node in DESC order:
$sql = "SELECT n.nid, r.vid, n.type, r.title, r.body, r.uid, r.timestamp FROM {node} n INNER JOIN {node_revisions} r ON n.nid = r.nid WHERE r.vid > n.vid ORDER BY r.vid DESC LIMIT %d";

Also, this query does not fetch those nodes having only one revision while unpublished (typically the first revision created by an author). Publishers will never be able to see those nodes in the Pending revisions queue until the authors edit the node and creates a new revision.

I'll post a patch for this bug asap.

Comments

eriktoyra’s picture

This patch selects only the most recent revision for a node and outputs it into the Pending revisions queue. It will also allow you to list the current revision of a node as long as it is unpublished (useful for when authors create the first revision).