Get latest revision vid in views I'm using the revisioning module to handle the status of nodes. As far as the nodes go, they've been working perfect and the work flow is exactly what I want. However, I'm running into an issue when trying to construct a view.

What I'm able to do so far:


Create the view
Set the node type
Limit it to only nodes that have pending revisions

(I get the two nodes with pending revisions (an unpublished rev)

Get the nid of the node


Where I'm having issues:


I try to select the vid of the pending revision, but instead I get the vid of the currently published revision.


I'm not sure where to go. I've tried using "Type: Content" and "Type: Content revision" and get the exact same behavior. I've tried playing with Relationships and still get the same behavior, but I don't think a relationship touches what I need.

... This is incredibly irritating because I'm obviously getting the pending nodes that I want, I'm just not getting the vid for what's pending (which is what my filter uses to get those nodes in the first place) and instead getting it for what's published.

I can imagine there might be some headache because it's possible to have multiple pending revisions, in that case, I should see two lines for that one nid since nid and vid /should/ be unique.
Instead of views_php use something like this. Add it as a field - you just need a custom handler to call the revisioning function that returns the latest vid.

/*
* Implements hook_views_data_alter().
*/
function MYMODULE_views_data_alter(&amp;$data) {
  $data['node_revision']['latest_revision'] = array(
    'title' =&gt; t('Latest revision'),
    'help' =&gt; t('Get the latest vid.'),
    'group' =&gt; t('Content revision'),
    'real field' =&gt; 'nid',
    'field' =&gt; array(
      'handler' =&gt; 'MYMODULE_field_handler_latest_revision',
      'click sortable' =&gt; TRUE,
    ),
  );
}


And the handler:

/**
 * Provide the latest revision number from the nid field.
 */
class MYMODULE_field_handler_latest_revision extends views_handler_field {

  // Return latest vid as the field value.
  public function render($values) {
    $value = $this-&gt;get_value($values);
    return revisioning_get_latest_revision_id($value);
  }
}