// the user is reverting back to an older revision
			// the problem here is that instead of telling me the most recent vid
			// drupal gives me the vid associated with whatever version we're reverting to
			// to get around that i do some sql magic to get the revision for this node directly preceding the newest one
			// i wish there was a better way to do it
			$old_vid = db_result(db_query('SELECT vid FROM {node_revisions} WHERE nid = %d ORDER BY timestamp DESC LIMIT 1', $node->nid));
<code>
</blockquote>
What if i have 5 revisions and switch from 3rd to 1st?
Why didn't you use <code>'SELECT vid FROM {node} WHERE nid = %d'

?
Since you query database before drupal saves node actual revision AFAIK stored there .

Comments

fasdalf@fasdalf.ru’s picture

Sorry. Missclicked Preview. It should be:

 // the user is reverting back to an older revision
// the problem here is that instead of telling me the most recent vid
// drupal gives me the vid associated with whatever version we're reverting to
// to get around that i do some sql magic to get the revision for this node directly preceding the newest one
// i wish there was a better way to do it
$old_vid = db_result(db_query('SELECT vid FROM {node_revisions} WHERE nid = %d ORDER BY timestamp DESC LIMIT 1', $node->nid));

What if i have 5 revisions and switch from 3rd to 1st?
Why didn't you use 'SELECT vid FROM {node} WHERE nid = %d'?
Since you query database before drupal saves node actual revision AFAIK stored there .